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

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Quicksort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage