Skip to main content
Log in

Hamiltonicity of k-Sided Pancake Networks with Fixed-Spin: Efficient Generation, Ranking, and Optimality

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

We present a Hamilton cycle in the k-sided pancake network and four combinatorial algorithms to traverse the cycle. The network’s vertices are coloured permutations \(\pi = p_1p_2\cdots p_n\), where each \(p_i\) has an associated colour in \(\{0,1,\ldots , k{-}1\}\). There is a directed edge \((\pi _1,\pi _2)\) if \(\pi _2\) can be obtained from \(\pi _1\) by a “flip” of length \(\ell \), which reverses the first \(\ell \) elements and increments their colour modulo k. Our particular cycle is created using a greedy min-flip strategy, and the average flip length of the edges we use is bounded by a constant. By reinterpreting the order recursively, we can generate successive coloured permutations in O(1)-amortized time, or each successive flip by a loop-free algorithm. We also show how to compute the successor of any coloured permutation in O(n) time. Our greedy min-flip construction generalizes known Hamilton cycles for the pancake network (where \(k=1\)) and the burnt pancake network (where \(k=2\)). Interestingly, a greedy max-flip strategy works on the pancake and burnt pancake networks, but it does not work on the k-sided network when \(k>2\). In addition to our generation results, we provide ranking and unranking algorithms for our Hamiltion cycle that run in \(O(n^2)\) time, and show that the cycle is globally optimal in terms of minimizing the total number of pancakes that are flipped. Finally, we characterize the Hamiltonicity of k-sided pancake networks with any fixed “spin” s.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6

Similar content being viewed by others

Notes

  1. Some unusual data structures can support flips of any lengths in constant time [49].

  2. Here a subsequence refers to consecutive (i.e., neighbouring) values in the sequence.

  3. A touton (or tiffin) is a piece of fried or baked bread dough that is a traditional dish from Newfoundland and Labrador. It resembles a square pancake, and is often served with butter, jam, molasses, or maple syrup. These serve as close approximations of real-world square pancakes.

References

  1. Akers, S., Krishnamurthy, B.: A group-theoretic model for symmetric interconnection networks. Computers, IEEE Transactions on 38(4), 555–566 (1989)

    Article  MathSciNet  MATH  Google Scholar 

  2. Athanasiadis, C.A.: Binomial Eulerian polynomials for colored permutations. J. Combin. Theory Ser. A 173, 105214 (2020)

    Article  MathSciNet  MATH  Google Scholar 

  3. Bagno, E., Garber, D., Mansour, T.: On the group of alternating colored permutations. Electron. J. Combin. 21(2), Paper 2.29 (2014)

  4. Borodin, A.: Longest increasing subsequences of random colored permutations. Electron. J. Combin. 6(13), 12 (1999)

    MathSciNet  MATH  Google Scholar 

  5. Cameron, B., Sawada, J., Williams, A.: A Hamilton cycle in the \(k\)-sided pancake network. In: Flocchini, P., Moura, L. (eds.) IWOCA ’21: 32nd International Workshop on Combinatorial Algorithms. Lecture Notes in Computer Science, vol. 12757, pp. 137–151. Springer, Ottawa, ON, Canada (2021)

    Google Scholar 

  6. Cardinal, J., Merino, A., Mütze, T.: Efficient generation of elimination trees and graph associahedra. In: Proceedings of the 2022 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2128–2140. SIAM, (2022)

  7. Chen, W.Y.C., Gao, H.Y., He, J.: Labeled partitions with colored permutations. Discrete Math. 309(21), 6235–6244 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  8. Cohen, D.S., Blum, M.: On the problem of sorting burnt pancakes. Discrete Appl. Math. 61(2), 105–120 (1995)

    Article  MathSciNet  MATH  Google Scholar 

  9. COS++. The Combinatorial Object Server. http://combos.org/cperm

  10. Doleman, J., et al.: Campanalogia Improved: Or, the Art of Ringing Made Easy,... C. Hitch and L. Hawes; and J. Hodges, 1733

  11. Duane, A., Remmel, J.: Minimal overlapping patterns in colored permutations. Electron. J. Combin. 18(2), Paper 25, 38 (2011)

  12. Duckworth, R., Stedman, F.: Tintinnalogia: Or, The Art of Ringing. London, (1668)

  13. Duckworth, R., Stedman, F.: Tintinnalogia: Or, The Art of Ringing, Kingsmead Reprints (1970)

  14. Dweighter, H.: Problem E2569. Amer. Math. Monthly 82, 1010 (1975)

    MathSciNet  Google Scholar 

  15. Eppstein, D.: An almost-forgotten combinatorist: Heinrich August Rothe. https://11011110.github.io/blog/2012/03/27/almost-forgotten-combinatorist-heinrich.html, (2012)

  16. Essed, H., Therese, W.: The harassed waitress problem. In: Ferro, A., Luccio, F., Widmayer, P. (eds), Fun with Algorithms, volume 8496 of Lecture Notes in Computer Science, pages 325–339. Springer International Publishing, (2014)

  17. Fertin, G., Labarre, A., Rusu, I., Tannier, E., Vialette, S.: Combinatorics of Genome Rearrangements. MIT Press, Cambridge (2009)

    Book  MATH  Google Scholar 

  18. Gates, W.H., Papadimitriou, C.H.: Bounds for sorting by prefix reversal. Discrete Math. 27(1), 47–57 (1979)

    Article  MathSciNet  MATH  Google Scholar 

  19. Gray, F.: Pulse code communication. U.S. Patent 2,632,058, (1947)

  20. Hartung, E., Hoang, H., Mütze, T., Williams, A.: Combinatorial generation via permutation languages. i. fundamentals. Trans. Am. Math. Soc. 375(04), 2255–2291 (2022)

    Article  MathSciNet  MATH  Google Scholar 

  21. Hartung, E., Hoang, H.P., Mütze, T., Williams, A.: Combinatorial generation via permutation languages. In Proceedings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1214–1225. SIAM, (2020)

  22. Heydari, M.H., Sudborough, I.H.: On the diameter of the pancake network. J. Algorithms 25(1), 67–94 (1997)

    Article  MathSciNet  MATH  Google Scholar 

  23. Hindenburg, C.F.: Sammlung combinatorisch-analytischer Abhandlungen, volume 1. ben Gerhard Fleischer dem Jungern, (1796)

  24. Holroyd, A.E.: Perfect snake-in-the-box codes for rank modulation. IEEE Trans. Inf. Theory 63(1), 104–110 (2016)

    Article  MathSciNet  MATH  Google Scholar 

  25. Hunt, K.: The art of changes: bell-ringing, anagrams, and the culture of combination in seventeenth-century england. Journal of Medieval and Early Modern Studies 48(2), 387–412 (2018)

    Article  Google Scholar 

  26. Johnson, S.M.: Generation of permutations by adjacent transposition. Math. Comput. 17(83), 282–285 (1963)

    Article  MathSciNet  MATH  Google Scholar 

  27. Justan, M.P., Muga, F.P., Sudborough, I.H.: On the generalization of the pancake network. In Proceedings International Symposium on Parallel Architectures, Algorithms and Networks. I-SPAN’02, pages 173–178, (2002)

  28. Kaneko, K.: Hamiltonian cycles and Hamiltonian paths in faulty burnt pancake graphs. IEICE - Trans. Inf. Syst. E90–D(4), 716–721 (2007)

    Article  Google Scholar 

  29. Knor, M.: Gray codes in graphs. Math. Slovaca 44(4), 395–412 (1994)

    MathSciNet  MATH  Google Scholar 

  30. Knuth, D.E.: The Art of Computer Programming, volume 4: Combinatorial Algorithms, Part 1. Addison-Wesley, (2010)

  31. Mansour, T.: Pattern avoidance in coloured permutations. Sém. Lothar. Combin., 46:Art. B46g, 12, (2001/02)

  32. Mansour, T.: Coloured permutations containing and avoiding certain patterns. Ann. Comb. 7(3), 349–355 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  33. McGuire, G.: Bells, motels and permutation groups. arXiv preprint arXiv:1203.1835, (2012)

  34. Merino, A., Mütze, T., Williams, A.: All Your bases Are Belong to Us: Listing All Bases of a Matroid by Greedy Exchanges. In: Fraigniaud, P., Uno, Y. (eds), 11th International Conference on Fun with Algorithms (FUN 2022), volume 226 of Leibniz International Proceedings in Informatics (LIPIcs), pages 22:1–22:28, Dagstuhl, Germany, 2022. Schloss Dagstuhl – Leibniz-Zentrum für Informatik

  35. Ord-Smith, R.: Generation of permutations in pseudolexicographic order. Commun. ACM 10(7), 452 (1967)

    Google Scholar 

  36. Ord-Smith, R.: Generation of permutation sequences: Part 2. Comput. J. 14(2), 136–139 (1971)

    Article  MATH  Google Scholar 

  37. Sawada, J., Williams, A.: Greedy flipping of pancakes and burnt pancakes. Discrete Appl. Math. 210, 61–74 (2016)

    Article  MathSciNet  MATH  Google Scholar 

  38. Sawada, J., Williams, A.: Successor rules for flipping pancakes and burnt pancakes. Theoret. Comput. Sci. 609(part 1), 60–75 (2016)

    Article  MathSciNet  MATH  Google Scholar 

  39. Sedgewick, R.: Permutations generation methods. ACM Comput. Surv. 9(2), 137–164 (1977)

    Article  MathSciNet  MATH  Google Scholar 

  40. Shin, H., Zeng, J.: Symmetric unimodal expansions of excedances in colored permutations. European J. Combin. 52(part A), 174–196 (2016)

    Article  MathSciNet  MATH  Google Scholar 

  41. Singh, S.: Flipping pancakes with mathematics. The Guardian, (2013)

  42. Stedman, F.: Campanalogia: or the Art of Ringing Improved, With plain and easie rules to guide the Practitioner in the Ringing all kinds of Changes, To Which is added, great variety of New Peals. London, (1677)

  43. Steinhaus, H.: One hundred problems in elementary mathematics. Basic Books, (1964)

  44. Stigler, S.M.: Stigler’s law of eponymy. Trans. N. Y. Acad. Sci. 39(1 Series II), 147–157 (1980)

    Article  Google Scholar 

  45. Trotter, H.F.: Algorithm 115: perm. Commun. ACM 5(8), 434–435 (1962)

    Article  Google Scholar 

  46. Trust, H.: Record 000208301. https://catalog.hathitrust.org/Record/000208301

  47. Verhoeff, T.: The spurs of dh lehmer. Des. Codes Crypt. 84(1), 295–310 (2017)

    Article  MathSciNet  MATH  Google Scholar 

  48. White, A.T.: Fabian stedman: The first group theorist? Am. Math. Mon. 103(9), 771–778 (1996)

    Article  MathSciNet  MATH  Google Scholar 

  49. Williams, A.: O(1)-time unsorting by prefix-reversals in a boustrophedon linked list. In 5th International Conference on FUN with Algorithms, volume 6099 of Lecture Notes in Computer Science, pages 368–379. Springer, (2010)

  50. Williams, A.: The greedy Gray code algorithm. In Algorithms and Data Structures Symposium, WADS 2013, volume LNCS 8037, pages 525–536, (2013)

  51. Williams, A., Sawada, J.: Greedy pancake flipping. In The VII Latin-American Algorithms, Graphs and Optimization Symposium (LAGOS 2013), volume 45, pages 357–362, (2013)

  52. Zaks, S.: A new algorithm for generation of permutations. BIT 24(2), 196–204 (1984)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgements

We’d like to thank Torsten Mütze for helpful discussions on the history of the min-flip algorithm for permutations, and its connection to Algorithm J.

Funding

The research of Joe Sawada is supported by the Natural Sciences and Engineering Research Council of Canada (NSERC) grant RGPIN-2018-04211.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Aaron Williams.

Ethics declarations

Conflicts of interest

The authors have no known conflicts of interest to declare.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendices

Appendix

An Example Illustrating the Auxiliary Variable for the Loop-Free Generation

The following array (read top to bottom, then left to right) shows how the \(c_i\)’s and \(f_i\)’s evolve for each flip generated by FlipSeq for \(\sigma _{3, 3}\). Each entry corresponds to the flip in the same position in the array to the right of the vertical bar in Example 2. Each entry is a \(2\times 3\) matrix of the form \(\begin{pmatrix} c_1 &{} c_2 &{} c_3 \\ f_1 &{} f_2 &{} f_3 \end{pmatrix} \). Note that \(c_4=0\) except for in the last entry where \(c_4=1\) and \(f_4\) is always equal to 4, so we chose to omit these.

Rights and permissions

Springer Nature or its licensor holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Springer Nature or its licensor holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Cameron, B., Sawada, J., Therese, W. et al. Hamiltonicity of k-Sided Pancake Networks with Fixed-Spin: Efficient Generation, Ranking, and Optimality. Algorithmica 85, 717–744 (2023). https://doi.org/10.1007/s00453-022-01022-x

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-022-01022-x

Navigation