Programming Question

Question: Imagine you have a stack of n pancakes, each with a different diameter. You also have a pancake flipper. You can insert your flipper into the stack at any point, lift up all the pancakes in the substack above the flipper and flip them over as a unit. In the worst case, how many flips will it take you to sort all the pancakes by size (largest at the bottom) using an optimal algorithm?

From: Programming Interviews Exposed

Subject: Sorting and Searching

Load Another Question


Select a Subject