Skip to main content
Log in

Constructing the first (and coolest) fixed-content universal cycle

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

We explicitly construct the first universal cycles for strings with fixed-content—also known as strings with the same Parikh vector, or multiset permutations—using their shorthand encoding, which omits the final symbol as it is redundant. For example, 112312131132 is a universal cycle for content \(S = \{1,1,2,3\}\). Its first three windows—112, 123, and 231—are the shorthand representatives of 1123, 1231, and 2311, respectively. Our first construction \(\mathcal {V}(S)\) applies the classic cycle-joining approach on the first-inversion tree of necklace cycles with content S. For example, when \(S = \{1,1,2,3\}\) the root is the necklace cycle 1123 and its children are \(1\underline{21}3\) and \(11\underline{32}\) by swapping their first (i.e., leftmost) inversions. From this construction, we derive a successor rule to generate successive symbols of \(\mathcal {V}(S)\) in O(n)-time, where \(n=|S|\) is the cardinality of S. Our second construction \(\mathcal {U}(S)\) concatenates fixed-content necklaces together in a cool-lex order using the necklace-prefix algorithm. For example, \(\mathcal {U}(S) = 1123 \cdot 1213 \cdot 1132\) for \(S = \{1,1,2,3\}\). Central to this construction is the first shift Gray code for fixed-content necklaces, and a new efficient algorithm for generating these strings. From this construction, we can generate successive symbols of \(\mathcal {U}(S)\) in O(1)-amortized time while using O(n)-space. We complete our investigation with a pleasant surprise: \(\mathcal {V}(S) = \mathcal {U}(S)\). Our new results simultaneously generalize universal cycle constructions of shorthand permutations by Ruskey et al. (Algorithmica 64, 2012) and shorthand fixed-weight binary strings by Ruskey et al. (SIAM J Disc Math 26(2):605–617, 2012). They also provide a prefix-shift Gray code for multiset permutations in which the first symbol moves into the last or second-last position, which tightens the previous prefix-shift Gray code by Williams (Proceedings of the Twentieth Annual ACM-SIAM Symposium on Discrete Algorithms, 2009). Finally, we draw parallels between our constructions and the well-known granddaddy de Bruijn sequence for binary strings.

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
Fig. 7
Fig. 8
Fig. 9

Similar content being viewed by others

Notes

  1. Universal cycles can also be defined for objects other than strings (e.g., graphs [3]).

  2. This generalizes the decreasing spanning tree presented in [24], but with the relative values of the symbols inverted.

  3. In this presentation, we use the lexicographically smallest representative for necklaces rather than the lexicographically largest.

  4. Note that the aperiodic prefix of a necklace of length n is a Lyndon word whose length divides n.

  5. In nature, a scut is a short tail. Here, it is a suffix of tail(S) with a small symbol prepended.

  6. In contrast, the swaps used in the Steinhaus-Johnson-Trotter order [48] cause up to three edges to be changed.

References

  1. Avila, T., Corberán, A., Plana, I., Sanchis, J.M.: The stacker crane problem and the directed general routing problem. Networks 65(1), 43–55 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  2. Booth, K.S.: Lexicographically least circular substrings. Inf. Process. Lett. 10(4/5), 240–242 (1980)

    Article  MathSciNet  MATH  Google Scholar 

  3. Brockman, G., Kay, B., Snively, E.E.: On universal cycles of labeled graphs. Electron. J. Comb. 17(R4), 1 (2010)

    MathSciNet  MATH  Google Scholar 

  4. Cantwell, A., Geraci, J., Godbole, A., Padilla, C.: Graph universal cycles of combinatorial objects. Adv. Appl. Math. 127, 102166 (2021)

    Article  MathSciNet  MATH  Google Scholar 

  5. Cheng, Y.: Generating combinations by three basic operations. J. Comput. Sci. Technol. 22(6), 909–913 (2007)

    Article  MathSciNet  Google Scholar 

  6. Chung, F., Diaconis, P., Graham, R.: Universal cycles for combinatorial structures. Discret. Math. 110(1), 43–59 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  7. Compton, R.C., Gill Williamson, S.: Doubly adjacent gray codes for the symmetric group. Linear Multilinear Algebra 35(3–4), 237–293 (1993)

    Article  MathSciNet  MATH  Google Scholar 

  8. Corbett, P.F.: Rotator graphs: an efficient topology for point-to-point multiprocessor networks. IEEE Trans. Parallel Distrib. Syst. 3(05), 622–626 (1992)

    Article  Google Scholar 

  9. de Bruijn, N.G.: A combinatorial problem. Proc. Koninklijke Nederlandse Academie van Wetenschappen 49, 758–764 (1946)

    MATH  Google Scholar 

  10. de Bruijn, N. G.: Acknowledgement of priority to c. flye sainte-marie on the counting of circular arrangements of \(2^{n}\) zeros and ones that show each n-letter word exactly once. (1975)

  11. Diaconis, P., Graham, R. L.: Products of universal cycles, In A Lifetime of Puzzles. Demaine, E., Demaine, M., Rodgers, T.: eds., A K Peters/CRC Press, pp 35–55, (2008)

  12. Dragon, P.B., Hernandez, O.I., Sawada, J., Williams, A., Wong, D.: Constructing de Bruijn sequences with co-lexicographic order: The k-ary grandmama sequence. Eur. J. Comb. 72, 1–11 (2018)

    Article  MathSciNet  MATH  Google Scholar 

  13. Etzion, T.: An algorithm for constructing \(m\)-ary de Bruijn sequences. J. Algorithms 7(3), 331–340 (1986)

    Article  MathSciNet  MATH  Google Scholar 

  14. Etzion, T., Lempel, A.: Algorithms for the generation of full-length shift-register sequences. IEEE Trans. Inform. Theory 30(3), 480–484 (1984)

    Article  MathSciNet  MATH  Google Scholar 

  15. Fredricksen, H., Kessler, I.: An algorithm for generating necklaces of beads in two colors. Discrete Math. 61(2), 181–188 (1986)

    Article  MathSciNet  MATH  Google Scholar 

  16. Fredricksen, H., Maiorana, J.: Necklaces of beads in \(k\) colors and \(k\)-ary de Bruijn sequences. Discrete Math. 23, 207–210 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  17. Gabric, D., Sawada, J.: Constructing de Bruijn sequences by concatenating smaller universal cycles. Theoret. Comput. Sci. 743, 12–22 (2018)

    Article  MathSciNet  MATH  Google Scholar 

  18. Gabric, D., Sawada, J., Williams, A., Wong, D.: A framework for constructing de Bruijn sequences via simple successor rules. Discret. Math. 341(11), 2977–2987 (2018)

    Article  MathSciNet  MATH  Google Scholar 

  19. Gabric, D., Sawada, J., Williams, A., Wong, D.: A successor rule framework for constructing \(k\)-ary de Bruijn sequences and universal cycles. IEEE Trans. Inf. Theory 66(1), 679–687 (2020)

    Article  MathSciNet  MATH  Google Scholar 

  20. Gao, A.L., Kitaev, S., Steiner, W., Zhang, P.B.: On a greedy algorithm to construct universal cycles for permutations. Int. J. Found. Comput. Sci. 30(01), 61–72 (2019)

    Article  MathSciNet  MATH  Google Scholar 

  21. Gilbert, E.N., Riordan, J.: Symmetry types of periodic sequences. Illinois J. Math. 5(4), 657–665 (1961)

    Article  MathSciNet  MATH  Google Scholar 

  22. Golomb, S. W.: Shift register sequences: secure and limited-access code generators, efficiency code generators, prescribed property generators, mathematical models. World Scientific, 3rd edition, (2017)

  23. Hierholzer, C.: Ueber die Möglichkeit, einen Linienzug ohne Wiederholung und ohne Unterbrechung zu umfahren. Math. Ann. 6, 30–32 (1873)

    Article  MathSciNet  MATH  Google Scholar 

  24. Holroyd, A.E., Ruskey, F., Williams, A.: Shorthand universal cycles for permutations. Algorithmica 64(2), 215–245 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  25. Horan, V., Hurlbert, G.: Universal cycles for weak orders. SIAM J. Discrete Math. 27(3), 1360–1371 (2013)

    Article  MathSciNet  MATH  Google Scholar 

  26. Jackson, B., Stevens, B., Hurlbert, G.: Research problems on Gray codes and universal cycles. Discret. Math. 309(17), 5341–5348 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  27. Jackson, B.W.: Universal cycles of k-subsets and k-permutations. Discret. Math. 117(1–3), 141–150 (1993)

    Article  MathSciNet  MATH  Google Scholar 

  28. Johnson, J.R.: Universal cycles for permutations. Discret. Math. 309(17), 5264–5270 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  29. Knuth, D.: The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1. Number pt. 1. Pearson Education (2014)

  30. Leitner, A., Godbole, A.: Universal cycles of classes of restricted words. Discret. Math. 310(23), 3303–3309 (2010)

    Article  MathSciNet  MATH  Google Scholar 

  31. Leitner, A., Godbole, A.: Universal cycles of classes of restricted words. Discret. Math. 310(23), 3303–3309 (2010)

    Article  MathSciNet  MATH  Google Scholar 

  32. Martin, M.H.: A problem in arrangements. Bull. Am. Math. Soc. 40(12), 859–864 (1934)

    Article  MathSciNet  MATH  Google Scholar 

  33. Rankin, R. A.: A campanological problem in group theory. In Mathematical Proceedings of the Cambridge Philosophical Society, vol. 44, pp 17–25. Cambridge University Press, (1948)

  34. Ruskey, F., Sawada, J., Williams, A.: Binary bubble languages and cool-lex Gray codes. J. Combin. Theory Ser. A 119(1), 155–169 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  35. Ruskey, F., Sawada, J., Williams, A.: De Bruijn sequences for fixed-weight binary strings. SIAM J. Discret. Math. 26(2), 605–617 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  36. Ruskey, F., Williams, A.: The coolest way to generate combinations. Discret. Math. 309(17), 5305–5320 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  37. Ruskey, F., Williams, A.: An explicit universal cycle for the \((n-1)\)-permutations of an \(n\)-set. ACM Trans. Algorithm 6(3), 45 (2010)

    Article  MathSciNet  MATH  Google Scholar 

  38. Rytter, W., Zuba, W.: Syntactic view of sigma-tau generation of permutations. Theoret. Comput. Sci. 882, 49–62 (2021)

    Article  MathSciNet  MATH  Google Scholar 

  39. Sarbazi-Azad, H.: Stupid sort: A new sorting algorithm. Newsletter of Computing Science Department, Univ. of Glasgow Vol. 599, 4 (2000)

  40. Sawada, J.: De Bruijn Sequence and Universal Cycle Constructions. http://debruijnsequence.org/. Accessed: 2021-12-31

  41. Sawada, J.: A fast algorithm to generate necklaces with fixed content. Theoret. Comput. Sci. 301(1), 477–489 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  42. Sawada, J., Williams, A.: A Gray code for fixed-density necklaces and Lyndon words in constant amortized time. Theoret. Comput. Sci. 502, 46–54, (2013). Generation of Combinatorial Structures

  43. Sawada, J., Williams, A.: A Hamilton path for the sigma-tau problem. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 568–575. SIAM, (2018)

  44. Sawada, J., Williams, A.: Solving the sigma-tau problem. ACM Trans. Algorithms 16(1), 1–17 (2019)

    Article  MathSciNet  MATH  Google Scholar 

  45. Sawada, J., Williams, A.: A universal cycle for strings with fixed-content (which are also known as multiset permutations). In Workshop on Algorithms and Data Structures, pp 599–612. Springer, (2021)

  46. Sawada, J., Williams, A., Wong, D.L Universal cycles for weight-range binary strings. In In: Lecroq T., Mouchard L. (eds) Combinatorial Algorithms (IWOCA 2013), pp 388–401. Springer, (2013)

  47. Sawada, J., Williams, A., Wong, D.: Generalizing the classic greedy and necklace constructions of de Bruijn sequences and universal cycles. Electron. J. Comb. 23(1), P1.24 (2016)

    Article  MathSciNet  MATH  Google Scholar 

  48. Steinhaus, H.: One hundred problems in elementary mathematics. Courier Corporation, (1979)

  49. Stevens, B., Williams, A.: Hamilton cycles in restricted and incomplete rotator graphs. J. Graph Algorithms Appl. 16(4), 785–810 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  50. Swan, R.G.: A simple proof of rankin’s campanological theorem. Am. Math. Mon. 106(2), 159–161 (1999)

    Article  MathSciNet  MATH  Google Scholar 

  51. van Aardenne-Ehrenfest, T.: Circuits and trees in oriented linear graphs. Simon Stevin 28, 203–217 (1951)

    MathSciNet  MATH  Google Scholar 

  52. Williams, A.: Loopless generation of multiset permutations using a constant number of variables by prefix shifts. In Proceedings of the Twentieth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA ’09, pp 987–996, USA, (2009). SIAM

  53. Williams, A.: Shift Gray codes. PhD thesis, University of Victoria, (2009)

  54. Williams, A.: The greedy gray code algorithm. In Workshop on Algorithms and Data Structures, pp 525–536. Springer, (2013)

  55. Wong, D.: A new universal cycle for permutations. Graphs Combin. 33(6), 1393–1399 (2017)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgements

We’d like to thank the anonymous referees for helpful comments and corrections.

Funding

Joe Sawada: Natural Sciences and Engineering Research Council of Canada (NSERC) grant RGPIN 400673-2012

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Aaron Williams.

Ethics declarations

Conflict of interest

The authors have no known conflicts of interest to declare.

Ethical Statement

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

Additional information

Publisher's Note

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

Appendices

Appendix A: Successor-rule approach to construct \(\mathcal {V}(S)\)

figure g

Appendix B: Concatenation approach to construct the reverse of \(\mathcal {U}(S)\)

figure h

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) 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

Sawada, J., Williams, A. Constructing the first (and coolest) fixed-content universal cycle. Algorithmica 85, 1754–1785 (2023). https://doi.org/10.1007/s00453-022-01047-2

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-022-01047-2

Keywords

Navigation