[go: up one dir, main page]

login
Search: a078941 -id:a078941
     Sort: relevance | references | number | modified | created      Format: long | short | data
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.
+10
8
0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 22
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
Kazuyuki Amano, (15/14)n Flips are (almost) Sufficient to Sort Heydari and Sudborough's Pancake Stack, IEICE Trans. Info. Sys. (2024). See p. 1.
Shogo Asai, Yuusuke Kounoike, Yuji Shinano and Keiichi Kaneko, Computing the Diameter of 17-Pancake Graph Using a PC Cluster, Proc. Euro-Par 2006, LNCS 4128, pp. 1114-1124, 2006 Springer Verlag.
Vineet Bafna and Pavel Pevzner, Genome rearrangements and sorting by reversals, SIAM Journal on Computing 25:272-289 (1996).
Anne Bergeron, A very elementary presentation of the Hannenhalli-Pevzner theory, Discrete Applied Mathematics 146:134-145 (2005).
Anne Bergeron, and Francois Strasbourg, Experiments in computing sequences of reversals, Proceedings of the First International Workshop on Algorithms in Bioinformatics, 2001, pp. 164-174. Berlin: Springer-Verlag.
Laurent Bulteau, Guillaume Fertin, Irena Rusu, Pancake Flipping is Hard, arXiv:1111.0434 [cs.CC], Nov 10, 2011.
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.
B. Chitturi, W. Fahle, Z. Meng, L. Morales, C. O. Shields, I. H. Sudborough and W. Voit, An (18/11)n upper bound for sorting by prefix reversals, Theoret. Comput. Sci. 410 (2009), no. 36, 3372-3390.
J. Cibulka, On average and highest number of flips in pancake sorting, Theoret. Comput. Sci. 412 (2011), 822-834
F. Javier de Vega, An extension of Furstenberg's theorem of the infinitude of primes, arXiv:2003.13378 [math.NT], 2020.
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.
W. H. Gates and C. H. Padadimitriou, Bounds for sorting by prefix reversal, Discrete Math. 27 (1979), 47-57.
Sridhar Hannenhalli and Pavel A. Pevzner, Transforming cabbage into turnip: polynomial algorithm for sorting signed permutations by reversals, Journal of the ACM 48:1-27 (1999).
Brian Hayes, Computing Science: Sorting out the genome, Amer. Scientist, 95 (2007), 386-391.
M. H. Heydari and I. Hal Sudborough, On the diameter of the pancake network,J. Algorithms 25 (1997) no 1, 67-94.
Yuichi Komano and Takaaki Mizuki, Card-Based Zero-Knowledge Proof Protocol for Pancake Sorting, Int'l Conf. Info. Tech. Comm. Sec., Innov. Security Sol. Info. Tech. Comm. (SecITC 2022), Lecture Notes Comp. Sci. (LNCS Vol. 13809), Springer, Cham, pp. 222-239.
Yuusuke Kounoike, Keiichi Kaneko and Yuji Shinano, Computing the Diameters of 14- and 15-pancake Graphs, Proc. International Symposium on Parallel Architectures, Algorithms and Networks(ISPAN 2005), pp. 490-495.
Marc Lebrun et al., The PCC Games List, Section V1N5.
Ed Pegg, Jr., Pancakes
Ivars Peterson, Pancake Sorting.
Ivars Peterson, Improved Pancake Sorting
J. Sawada and A. Williams, Successor rules for flipping pancakes and burnt pancakes, Preprint 2015; Theoretical Computer Science, Volume 609, Part 1, Jan 04 2016, Pages 60-75.
Simon Singh, Flipping pancakes with mathematics, Blog Posting, Nov 14 2013. [States that a(18)=20, a(19)=22]
N. J. A. Sloane, My favorite integer sequences, in Sequences and their Applications (Proceedings of SETA '98).
Katie Steckles and Brady Haran, Pancake Numbers, Numberphile video (2017).
Eric Tannier, and Marie-France Sagot, Sorting by reversals in subquadratic time, Proceedings of the 15th Annual Symposium on Combinatorial Pattern Matching, 2004, pp. 1-13. Berlin: Springer-Verlag.
Eric Weisstein's World of Mathematics, Pancake Sorting
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
First differences: A359141.
KEYWORD
nonn,nice,hard,more
AUTHOR
N. J. A. Sloane, Jan 17 2001, Oct 12 2007
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
Flipping burnt pancakes. Given a sorted stack of n burnt pancakes of different sizes (smallest on top, ..., largest at the bottom), each with its burnt side up, a(n) is the number of spatula flips needed to restore them to their initial order but with the burnt sides down.
+10
2
1, 4, 6, 8, 10, 12, 14, 15, 17, 18, 19, 21, 22, 23, 24, 26, 28, 29
OFFSET
1,2
COMMENTS
In a 'spatula flip', a spatula is inserted below any pancake and all pancakes above the spatula are lifted and replaced in reverse order.
It is conjectured that this initial configuration is a worst case for the general problem of sorting burnt pancakes. If so, then this sequence is identical to A078941.
REFERENCES
David S. Cohen and Manuel Blum, "On the problem of sorting burnt pancakes", Discrete Applied Math., 61 (1995) 105-120.
FORMULA
a(n) <= A078941(n). a(n+1) <= a(n) + 2. 3n/2 <= a(n) <= 47n/30 + c for some constant c.
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Dean Hickerson, Dec 18 2002
STATUS
approved
Maximal distance between two signed permutations of n elements.
+10
1
0, 1, 3, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
OFFSET
0,3
COMMENTS
See also the comments in A058986 for background information.
From Glenn Tesler: (Start)
Let d_max = a(n) be the maximal distance.
Then d_max = n for n=0,1,3; d_max = n+1 except for n=0,1,3; however, there are many permutations achieving the max, not just the 2 Gollan permutations as in the unsigned case.
The formula for reversal distance is d = n + 1 - c + h + f,
where c is the number of cycles in the breakpoint graph, h is the number of "hurdles" and f is the number of "fortresses" (0 or 1).
It turns out that c >= h+f.
This is because each hurdle is composed of one or more cycles, distinct from those in other hurdles, and fortresses can be worked into that, too.
So we may rewrite distance as d = n+1 - (c-h-f), where c-h-f>=0. Thus d_max <= n+1.
Except for n=0,1,3, it turns out we can make c-h-f=0.
When n=0: d(null,null) = 0, so d_max = 0 (has c=1, h=0)
When n=1: d( 1, -1 ) = 1, d( 1, 1 ) = 0, so d_max = 1 (first one has c=1, h=0)
When n=2: d( 2 1, 1 2 ) = 3, all other d(sigma, 1 2) < 3 (has c=h=1)
When n=3: d_max = 3 (25 solutions, found by brute force; 20 with c=1, h=0; 5 with c=2, h=1)
When n>3: d_max = n+1 and there are many solutions, obtained by creating a situation in which c=h, f=0. One of them is
n=2m: n 1 m+1 2 m+2 3 m+3 ... m-1 2m-1 m (has c=h=1)
n=2m+1: n 1 m+1 2 m+2 3 m+3 ... m 2m (has c=h=2)
Note that these are indeed signed permutations, in which all signs happen to be positive. This is because "hurdles" require all the signs to be the same.
Also note that these are just examples to show that at least one permutation has d=n+1, which proves d_max=n+1 by the bound; however, there are many more signed permutations that also achieve d=n+1. (End)
REFERENCES
Brian Hayes, Sorting out the genome, Amer. Scientist, 95 (2007), 386-391.
FORMULA
a(n) = n+1 except for n=0,1,3.
CROSSREFS
KEYWORD
nonn
AUTHOR
Brian Hayes, Oct 26 2007, based on email from Glenn Tesler (gptesler(AT)math.ucsd.edu)
STATUS
approved

Search completed in 0.010 seconds