Pancake sorting

Pancake sortingis the mathematical problem of sorting a disordered stack of pancakes in order of size when aspatulacan be inserted at any point in the stack and used to flip all pancakes above it.  Apancake numberis the minimum number of flips required for a given number of pancakes. In this form, the problem was first discussed by American geometerJacob E. Goodman.A variant of the problem is concerned withburntpancakes, where each pancake has a burnt side and all pancakes must, in addition, end up with the burnt side on bottom.
All sorting methods require pairs of elements to be compared. For the traditionalsorting problem, the usual problem studied is to minimize thenumber of comparisons required to sort a list. The number of actual operations, such as swapping two elements, is then irrelevant. For pancake sorting problems, in contrast, the aim is to minimize the number of operations, where the only allowed operations are reversals of the elements of someprefixof the sequence. Now, the number of comparisons is irrelevant.
The minimum number of flips required to sort any stack ofnpancakes has been shown to lie between⁠15/14⁠nand⁠18/11⁠n(approximately 1.07nand 1.64n), but the exact value is not known.
The simplest pancake sorting algorithm performs at most2n− 3flips. In this algorithm, a kind ofselection sort, we bring the largest pancake not yet sorted to the top with one flip; take it down to its final position with one more flip; and repeat this process for the remaining pancakes.
In 1979,Bill GatesandChristos Papadimitriougave a lower bound of⁠17/16⁠n(approximately 1.06n) flips and an upper bound of⁠(5n+5)/3⁠. The upper bound was improved, thirty years later, to⁠18/11⁠nby a team of researchers at theUniversity of Texas at Dallas, led by Founders ProfessorHal Sudborough.
In 2011, Laurent Bulteau, Guillaume Fertin, and Irena Rusuproved that the problem of finding the shortest sequence of flips for a given stack of pancakes isNP-hard, thereby answering a question that had been open for over three decades.
In a variation called theburnt 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. It is asigned permutation, and if a pancakeiis "burnt side up" a negative elementi`is put in place ofiin the permutation. In 2008, a group of undergraduates built abacterial computerthat can solve a simple example of the burnt pancake problem by programmingE. colito flip segments of DNA which are analogous to burnt pancakes. DNA has an orientation (5' and 3') and an order (promoter before coding). Even though the processing power expressed by DNA flips is low, the high number of bacteria in a culture provides a largeparallel computingplatform. The bacteria report when they have solved the problem by becoming antibiotic resistant.
The discussion above presumes that each pancake is unique, that is, the sequence on which the prefix reversals are performed is apermutation. However, "strings" are sequences in which a symbol can repeat, and this repetition may reduce the number of prefix reversals required to sort. Chitturi and Sudborough (2010) and Hurkens et al. (2007) independently showed that the complexity of transforming a compatible string into another with the minimum number of prefix reversals isNP-complete. They also gave bounds for the same. Hurkens et al. gave an exact algorithm to sort binary and ternary strings. Chitturi(2011) proved that the complexity of transforming a compatible signed string into another with the minimum number of signed prefix reversals—the burnt pancake problem on strings—is NP-complete.
The pancake sorting problem was first posed byJacob E. Goodman, writing under the pseudonym "Harry Dweighter" ("harried waiter").
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 is notable as the topic of the only well-known mathematics paper byMicrosoftfounderBill Gates(as William Gates), entitled "Bounds for Sorting by Prefix Reversal" and co-authored withChristos Papadimitriou. Published in 1979, it describes an efficient algorithm for pancake sorting.In addition, the most notable paper published byFuturamaco-creatorDavid X. Cohen(as David S. Cohen), co-authored withManuel Blum, concerned the burnt pancake problem.
The connected problems of signed sorting by reversals and sorting by reversals were also studied more recently. Whereas efficient exact algorithms have been found for the signed sorting by reversals,the problem of sorting by reversals has been proven to be hard even to approximate to within certain constant factor,and also proven to be approximable in polynomial time to within the approximation factor 1.375.
Ann-pancake graphis a graph whose vertices are the permutations ofnsymbols from 1 tonand its edges are given between permutations transitive by prefix reversals. It is aregular graphwith n! vertices, its degree is n−1. The pancake sorting problem and the problem to obtain thediameterof the pancake graph are equivalent.
The pancake graph of dimensionn, Pncan be constructed recursively from n copies of Pn−1, by assigning a different element from the set {1, 2, …, n} as a suffix to each copy.
Theirgirth:
The γ(Pn)genusof Pnis:
Since pancake graphs have many interesting properties such as symmetric and recursive structures, small degrees and diameters compared against the size of the graph, much attention is paid to them as a model of interconnection networks for parallel computers.When we regard the pancake graphs as the model of the interconnection networks, the diameter of the graph is a measure that represents the delay of communication.
The pancake graphs areCayley graphs(thus arevertex-transitive) and are especially attractive for parallel processing. They have sublogarithmic degree and diameter, and are relativelysparse(compared to e.g.hypercubes).
An example of the pancake sorting algorithm is given below inPython. The code is similar tobubble sortorselection sort.
Sequences fromThe Online Encyclopedia of Integer Sequences: