Question: Can i get complete solution for this problem please its from my Algorithms and Complexity class. The Pancake Problem A stack of n pancakes is
Can i get complete solution for this problem please its from my Algorithms and Complexity class.
The Pancake Problem
A stack of n pancakes is placed in front of you. You have a spatula which you can insert anywhere into the stack and flip over all the pancakes above the spatula. You want to arrange the pancakes in order of their diameter (they are perfectly round), and you want to use as few flips as possible. As an example suppose n = 6, and the pancakes are numbered 1 through 6 in order of their diameter with 1 the smallest and 6 the largest. Suppose the original order is 346215, and the left end of the sequence represents the top of the stack. In one flip I can get 643215 (by flipping the first three pancakes: 346), then in the next flip 512346, then 432156, then 123456, so four flips are enough in this case. Let F(n) be the worst case number of flips needed to arrange a stack of n pancakes. Find an efficient (in a worst case sense) algorithm for this problem, where efficiency is measured by the worst case number of flips. Remember that your algorithm should work for pancakes with any order. To start you off you should easily be able to show that F(n) is at most 2n. Next, reduce that bound a little more if you can. (Hint: first think about how to move the largest pancake to the bottom...)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
