|
|
A058986
|
|
Sorting by prefix reversal (or "flipping pancakes"). You can only reverse segments that include the initial term of the current permutation; a(n) is the number of reversals that are needed to transform an arbitrary permutation of n letters to the identity permutation.
|
|
8
|
|
|
0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 22
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
COMMENTS
|
"The chef in our place is sloppy and when he prepares a stack of pancakes they come out all different sizes. Therefore when I deliver them to a customer, on the way to the table I rearrange them (so that the smallest winds up on top and so on, down to the largest at the bottom) by grabbing several from the top and flipping them over, repeating this (varying the number I flip) as many times as necessary. If there are n pancakes, what is the maximum number of flips (as a function a(n) of n) that I will ever have to use to rearrange them?" [Dweighter]
J. K. McLean (jkmclean(AT)webone.com.au): If the worst case for n pancakes is x flips, then the worst case for n+1 pancakes can be no greater than x+2 flips. Getting the n+1 pancake to the bottom of the pile will require 0, 1 or 2 flips, after which you can sort the n remaining pancakes in at most x flips.
Comments based on email message from Brian Hayes, Oct 10 2007: (Start)
We are interested in the diameter of the graph where the vertices are all possible permutations of n elements and an edge connects p(i) and p(j) if some allowed reversal transforms p(i) into p(j).
There are at least two dimensions to consider in describing the various sorting-by-reversal problems: (a) Are the elements of the sequence signed or unsigned? and (b) Are we constrained to work only from one end of the sequence?
The standard pancake problem has unsigned elements and allows moves only from the top of the stack; the diameter is given by the present sequence.
The "burnt-pancake" problem has signed elements and allows moves only from the top of the stack. This is sequence A078941 (and also A078942).
The biologically-inspired sorting problems I was writing about in the Amer. Scientist 2007 column dispense with the one-end-only constraint. You're allowed to reverse any segment of contiguous elements, anywhere in the permutation. For the unsigned case, a(n) = n-1 (cf. Kececioglu and Sankoff).
Finally there is the signed case without the one-end constraint. This was the main subject of my column and corresponds to sequence A131209. (End)
Brian Goodwin (brian_goodwin(AT)yahoo.com), Aug 22 2005, comments that the terms so far match the beginning of the following triangle:
0
1
3 4 5
7 8 9 10 11
13 14 15 16 17 18 19
21 22 23 24 25 26 27 28 29
31 32 ...
Is this a coincidence? Answer from Mikola Lysenko (mclysenk(AT)mtu.edu), Dec 09 2006: Unfortunately, Yes! That triangular sequence has the closed form: a(n) = n - 1 + floor(sqrt(n-2)). However, Gates and Papadimitrou establish a lower bound on the pancake sequence of at least (17/16)*n. For sufficiently large n, this is always larger than the number in the triangle.
Marc Lebrun writes that in 1975 he was involved with a group called the "People's Computer Company" and among the many early computer games they created and popularized was one called "Reverse", which they published in their newspaper. See link.
M. Peczarski and I affirm the value a(19) = 22 as given by Simon Singh. Firstly, a(19) >= 22 as stated in the paper by Heydari Sudborough. This statement is mentioned on page 93. There two permutations of order 19 are given which need at least 22 flips. These permutations are 1,7,5,3,6,4,2,8,14,12,10,13,11,9,15,17,19,16,18 and 1,7,5,3,6,4,2,8,14,12,10,13,11,9,15,18,16,19,17. Making use of a branch-and-bound algorithm, we can confirm that their statement is correct. Together with the result that a(18) = 20, this gives a(19) = 22. Both values a(18) = 20 and a(19) = 22 were also proved in the paper by Cibulka. - Gerold Jäger, Oct 29 2020
|
|
REFERENCES
|
J. J. Chew, III (jjchew(AT)math.utoronto.ca), personal communication, Jan 15 and Feb 08 2001, computed a(10) - a(13).
E. Györi and G. Turán, Stack of pancakes, Studia Sci. Math. Hungar., 13 (1978), 133-137.
|
|
LINKS
|
Alberto Caprara, Sorting by reversals is difficult, Proceedings of RECOMB '97: The First International Conference on Computational Molecular Biology, 1997, pp. 75-83. New York: ACM Press.
Harry Dweighter ["Harried Waiter", pseudonym of Jacob E Goodman], Problem E2569, Amer. Math. Monthly, 82 (1975), 1010. Comments by M. R. Garey, D. S. Johnson and S. Lin, loc. cit. 84 (1977), 296.
|
|
FORMULA
|
It is known that a(n) >= n+1 for n >= 6, a(n) >= (17/16)*n if n is a multiple of 16 (so a(32) >= 34) and a(n) <= (5*n+5)/3.
There is an improved asymptotic upper bound of (18/11)*n + O(1) for the number of prefix reversals to sort permutations of length n given in the Chitturi et al. paper. - Ivan Hal Sudborough (hal_sud(AT)yahoo.com), Jul 02 2008
|
|
EXAMPLE
|
For n = 3, the stack of pancakes with radii (1, 3, 2) requires a(3) = 3 flips to sort: Starting with (1, 3, 2), flip the top two pancakes to get (3, 1, 2), then flip the entire stack to get (2, 1, 3), then flip the top two pancakes again to get (1, 2, 3).
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,nice,hard,more
|
|
AUTHOR
|
|
|
EXTENSIONS
|
Typo in value for a(5) corrected by Ed Pegg Jr, Jan 02 2002
a(14)-a(17) from Ivan Hal Sudborough (hal_sud(AT)yahoo.com), Jul 02 2008. The new upper bounds for n = 14, 15, 16 and 17 are found in the articles by Asai et al. and Kounoike et al.
Simon Singh's blog gives values for a(18) and a(19). It is not clear if these have been proved to be correct. - N. J. A. Sloane, Dec 11 2013
|
|
STATUS
|
approved
|
|
|
|