The purpose of this lab is to emphasis the operation of a


Pancake Sort

The purpose of this lab is to emphasis the operation of a stack. You will implement a "pancake sort", aptly named because you can envision the values that you are trying to sort as a stack of pancakes that you want to arrange to have the largest on the bottom and the smallest on top.

The complexity of this sort is that the only data structure you are allowed to use to hold values is a stack (other than simple integers or strings). So, the initial input, which is simply some list of integers, must be stored onto a stack as the values are read.

At each step, you may "flip" the stack to any depth that will move you closer to the ultimate goal stated above. So, for example, if I remove the top pancake and then decide that the second one should go on top of the first one, those two would need to flip. Note that as I remove the second one, I could decide that the third one should also be part of this flip.

You may use as many stacks as you need to accomplish the sort, but you cannot create any other aggregate data structures like a list.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: The purpose of this lab is to emphasis the operation of a
Reference No:- TGS01142070

Now Priced at $10 (50% Discount)

Recommended (98%)

Rated (4.3/5)