Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: Frank the frog dabbles in prognostications. He has projected the number of flies that will be around his lilypad loft on each of the

Question:

Frank the frog dabbles in prognostications. He has projected the number of flies that will be around his  Remember that your algorithm needs to output the optimal set of days for Frank to eat flies. You should both 



Frank the frog dabbles in prognostications. He has projected the number of flies that will be around his lilypad loft on each of the following n days. Thus, d days from now, there will be fa flies around his lilypad. Frank also is quite sleepy, and likes to rest for days at a time. The more he rests, the hungrier he gets. If Frank has rested for r days, he has the appetite for a, flies. Once he wakes on a day he eats and then his appetite resets and returns to 0. Recall, the more Frank rests, the hungrier he gets, so a; j: Return HUNGRYFROG(fi fn-j). (@j) Intuitively, the algorithm figures out how many days of rest j are needed to eat all of the flies on the last day. It wakes Frank up on the last day, and then accounts for the j days of rest needed to work up his appetite to eat as much as possible on the last day, and recursively considers the best solution for first n -j days. Explain why your instance causes the greedy algorithm to return the wrong answer. Solution: (b) Let OPT(j) be the maximum number of flies Frank can eat over the first days. Give a recurrence to compute OPT(j) from OPT(1)..... OPT(j-1). Give a few sentences justifying why your recurrence is correct. Solution: (c) Using your recurrence, design a dynamic programming algorithm to output the optimal set of days for Frank to wake up. You may use either a top-down or bottom-up approach.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The detailed answer for the above question is provided below Answer The greedy algorithm for the Frank the Frog problem works as follows Compute the smallest j such that aj fn Wake Frank up on day n I... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students also viewed these Algorithms questions