This activity is inspired by a problem first introduced in 1975 by Harry Dweighter in the American
Mathematical Monthly. The question is not only to sort the pancakes, but to determine f(n)
the minimal amount of flips mandated to sort any stack of size n
.
This problem is now famous because Bill Gates authored (with C. Papadimitriou) his only
scientific publication in 1979 on this topic, providing a faster algorithm and proving that 17n/16 ≤ f(n) ≤ (5n+5)/3
.
This was the only publication of Bill Gates before he invented Windows and became rich.
Then, David X. Cohen, the inventor of the Futurama comics with many mathematical references, introduced the variant with burnt pancakes and studied its complexity with Manuel Blum in 1993.
An article of 2012 (by L. Bulteau, G. Fertin and I. Rusu) proved that determining the minimal amount of flips to sort the stack is a NP-complete problem. Naturally, the stack sorting problem is not NP-complete since it can be solved in 2n-3 steps with the naive algorithm and (5n+5)/3 steps with the Gates algorithm. That's determining the minimal amount of steps that is NP.
Further information can be found on the wikipedia page, as usual.
This activity is also integrated to CSIRL (my repository of free unplugged activities to introduce computer science, available at http://www.loria.fr/~quinson/Mediation/SMN/), and it may be interesting to run the unplugged activities before implementing these algorithms in PLM.
As usual, there are several things that could be done in the code of this universe to improve it: