Algorithm problem w/ recurrence: Frying pancakes: a small pan can only hold two pancakes at a time. Each pancake needs to be fried on both sides. Frying one side takes 1 minute, no matter how many pancakes are on the pan. Consider this recursive algorithm: If n <= 2, fry the pancakes or the two pancakes together on each side. If n > 2, fry any two pancakes together on each side and then apply the same process recursively to the remaining n-2 pancakes. a. Set up and solve the recurrence for the amount of time this algorithm needs to fry n pancakes. b. Explain why this algorithm does not fry the pancakes in the minimum time for all n > 0. c. Give a correct recursive algorithm that executes the task in the minimum amount of time. > I was not sure how to start this. I have had trouble with recurrence in the past. Also from the work that I did do, I didn't know how there could be a better algorithm. Thanks in advance
Frying pancakes: a small pan can only hold two pancakes at a time. Each pancake needs to be fried on both sides. Frying one side takes 1 minute, no matter how many pancakes are on the pan. Consider this recursive algorithm:
If n <= 2, fry the pancakes or the two pancakes together on each side.
If n > 2, fry any two pancakes together on each side and then apply the same process recursively to the remaining n-2 pancakes.
a. Set up and solve the recurrence for the amount of time this algorithm needs to fry n pancakes.
b. Explain why this algorithm does not fry the pancakes in the minimum time for all n > 0.
c. Give a correct recursive algorithm that executes the task in the minimum amount of time.
> I was not sure how to start this. I have had trouble with recurrence in the past. Also from the work that I did do, I didn't know how there could be a better algorithm. Thanks in advance
Trending now
This is a popular solution!
Step by step
Solved in 3 steps