Definitions

Pancake sorting

Pancake sorting is a variation of the sorting problem in which the only allowed operation is to reverse the elements of some prefix of the sequence. Unlike a traditional sorting algorithm, which attempts to sort with the least comparisons possible, the goal is to sort the sequence in as few reversals as possible. This operation can be visualized by thinking of a stack of pancakes in which one is allowed to take the top k pancakes and flip them.

The theoretically fastest algorithm has been shown to lie between (17/16)n and (5/3)n complexity, but the exact value is not known.

The simplest pancake sorting algorithm requires at most 2n−3 flips. In this algorithm, a variation of selection sort, we bring the largest pancake not yet sorted to the top with one flip, and then take it down to its final position with one more, then repeat this for the remaining pancakes. Note that we do not count the time needed to find the largest pancake, only the number of flips; if we wished to create a real machine to execute this algorithm in linear time, it would have to both perform prefix reversal (flips) and be able to find the maximum of a range of consecutive numbers in constant time.

In a more difficult variation called the Burnt Pancake Problem, the bottom of each pancake in the pile is burnt, and the sort must be completed with the burnt side of every pancake down. The above simplistic algorithm also works for this problem, but some faster algorithms do not. In 2008, a group of undergraduates built a bacterial computer that can solve a simple example of the burnt pancake problem by programming E. coli to flip segments of DNA which are analogous to burnt pancakes. DNA has an orientation (5' and 3') and an order (promoter before coding). The bacteria report when they have solved the problem by becoming antibiotic resistant.

Although seen more often as an educational device, pancake sorting also appears in applications in parallel processor networks, in which it can provide an effective routing algorithm between processors.

The problem can be considered notable in cultural trivia, as the only well-known paper ever written by Microsoft Chairman and billionaire Bill Gates (as William Gates), entitled "Bounds for Sorting by Prefix Reversal" and published in 1979, describes an efficient algorithm for pancake sorting. In addition, the most notable paper published by Futurama co-creator David X. Cohen (as David S. Cohen) concerned the burnt pancake problem. Their collaborators were Christos Papadimitriou (then at Harvard, now at Berkeley) and Manuel Blum (then at Berkeley, now at Carnegie Mellon University), respectively.

On September 17, 2008, a team of researchers at the University of Texas at Dallas led by Founders Professor Hal Sudborough announced the acceptance by the journal Theoretical Computer Science of a more efficient algorithm for pancake sorting than the one proposed by Gates and Papadimitriou.

Related Integer Sequences

The following describes the number of flips per specified stack height. the first number is the height of the pancake stack. The following numbers are the number of stacks of that height that require 0, 1, 2, . . . flips to get to the sorted stack.

• 1 - 1
• 2 - 1 1
• 3 - 1 2 2 1
• 4 - 1 3 6 11 3
• 5 - 1 4 12 35 48 20
• 6 - 1 5 20 79 199 281 133 2
• 7 - 1 6 30 149 543 1357 1903 1016 35
• 8 - 1 7 42 251 1191 4281 10561 15011 8520 455
• 9 - 1 8 56 391 2278 10666 38015 93585 132697 79379 5804
• 10 - 1 9 72 575 3963 22825 106461 377863 919365 1309756 814678 73232
• 11 - 1 10 90 809 6429 43891 252737 1174766 4126515 9981073 14250471 9123648 956354 6
• 12 - 1 11 110 1099 9883 77937 533397 3064788 14141929 49337252 118420043 169332213 111050066 13032704 167

Sequences from The Online Encyclopedia of Integer Sequences:

References

• Gates, W. and Papadimitriou, C. "Bounds for Sorting by Prefix Reversal." Discrete Mathematics. 27, 47-57, 1979.
• Cohen D.S. and Blum, M. "On the problem of sorting burnt pancakes." Discrete Applied Mathematics. 61, 105-120, 1995.