Earlier quoted context omitted.
How about this: > In 1979, Bill Gates and Christos Papadimitriou[3] gave an upper bound of (5/3)n. This was improved, thirty years later, to (18/11)n by a team of researchers at the University of Texas at Dallas, led by Founders Professor Hal Sudborough[4] (Chitturi et al., 2009). https://en.wikipedia.org/wiki/Pancake_sorting Not easy to have significant algorithmic-complexity results that have stood as an upper boun…
Hey, that's the official name for what I thought of as "aligning a stack of coins". The Google Code Jam qualification round this year included the problem "write a function to report the minimum number of flips necessary to sort a stack of pancakes". I'm not too pleased to see this in the wikipedia page: > The minimum number of flips required to sort any stack of n pancakes has been shown to lie between ~1.07n and 1.…
I guess for completeness, I should post the solution to the sortless burnt pancake (to me, "coin alignment") problem:
Consider a stack of coins, like top-HTTHHTTHTHTTTTTTH-bottom. The number of flips required to align it is equal to the number of transitions from tails to heads or heads to tails as you move through the stack. In the example, we can break the stack conceptually into runs of H TT HH TT H T H TTTTT H, which is 8 transitions.
1. (This number is necessary.) Two adjacent coins which differ in orientation can only be made not to differ by a flip at the position between them. A flip above or below that position in the stack reverses neither or both, which preserves their difference. Stated another way, no flip can reduce the number of transitions in the stack by more than 1.
2. (This number is sufficient.) If you move from the top of the stack down, flipping whenever a transition is encountered, you preserve the invariant that the prefix of the stack above the point you have reached is all aligned. This is one flip per transition, so one flip per transition suffices.
If the coins must be aligned to a particular direction, for example heads up, just suffix a coin of that alignment to the bottom of the stack.