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.
Similar content being viewed by others
Notes
Universal cycles can also be defined for objects other than strings (e.g., graphs [3]).
This generalizes the decreasing spanning tree presented in [24], but with the relative values of the symbols inverted.
In this presentation, we use the lexicographically smallest representative for necklaces rather than the lexicographically largest.
Note that the aperiodic prefix of a necklace of length n is a Lyndon word whose length divides n.
In nature, a scut is a short tail. Here, it is a suffix of tail(S) with a small symbol prepended.
In contrast, the swaps used in the Steinhaus-Johnson-Trotter order [48] cause up to three edges to be changed.
References
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)
Booth, K.S.: Lexicographically least circular substrings. Inf. Process. Lett. 10(4/5), 240–242 (1980)
Brockman, G., Kay, B., Snively, E.E.: On universal cycles of labeled graphs. Electron. J. Comb. 17(R4), 1 (2010)
Cantwell, A., Geraci, J., Godbole, A., Padilla, C.: Graph universal cycles of combinatorial objects. Adv. Appl. Math. 127, 102166 (2021)
Cheng, Y.: Generating combinations by three basic operations. J. Comput. Sci. Technol. 22(6), 909–913 (2007)
Chung, F., Diaconis, P., Graham, R.: Universal cycles for combinatorial structures. Discret. Math. 110(1), 43–59 (1992)
Compton, R.C., Gill Williamson, S.: Doubly adjacent gray codes for the symmetric group. Linear Multilinear Algebra 35(3–4), 237–293 (1993)
Corbett, P.F.: Rotator graphs: an efficient topology for point-to-point multiprocessor networks. IEEE Trans. Parallel Distrib. Syst. 3(05), 622–626 (1992)
de Bruijn, N.G.: A combinatorial problem. Proc. Koninklijke Nederlandse Academie van Wetenschappen 49, 758–764 (1946)
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)
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)
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)
Etzion, T.: An algorithm for constructing \(m\)-ary de Bruijn sequences. J. Algorithms 7(3), 331–340 (1986)
Etzion, T., Lempel, A.: Algorithms for the generation of full-length shift-register sequences. IEEE Trans. Inform. Theory 30(3), 480–484 (1984)
Fredricksen, H., Kessler, I.: An algorithm for generating necklaces of beads in two colors. Discrete Math. 61(2), 181–188 (1986)
Fredricksen, H., Maiorana, J.: Necklaces of beads in \(k\) colors and \(k\)-ary de Bruijn sequences. Discrete Math. 23, 207–210 (1978)
Gabric, D., Sawada, J.: Constructing de Bruijn sequences by concatenating smaller universal cycles. Theoret. Comput. Sci. 743, 12–22 (2018)
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)
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)
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)
Gilbert, E.N., Riordan, J.: Symmetry types of periodic sequences. Illinois J. Math. 5(4), 657–665 (1961)
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)
Hierholzer, C.: Ueber die Möglichkeit, einen Linienzug ohne Wiederholung und ohne Unterbrechung zu umfahren. Math. Ann. 6, 30–32 (1873)
Holroyd, A.E., Ruskey, F., Williams, A.: Shorthand universal cycles for permutations. Algorithmica 64(2), 215–245 (2012)
Horan, V., Hurlbert, G.: Universal cycles for weak orders. SIAM J. Discrete Math. 27(3), 1360–1371 (2013)
Jackson, B., Stevens, B., Hurlbert, G.: Research problems on Gray codes and universal cycles. Discret. Math. 309(17), 5341–5348 (2009)
Jackson, B.W.: Universal cycles of k-subsets and k-permutations. Discret. Math. 117(1–3), 141–150 (1993)
Johnson, J.R.: Universal cycles for permutations. Discret. Math. 309(17), 5264–5270 (2009)
Knuth, D.: The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1. Number pt. 1. Pearson Education (2014)
Leitner, A., Godbole, A.: Universal cycles of classes of restricted words. Discret. Math. 310(23), 3303–3309 (2010)
Leitner, A., Godbole, A.: Universal cycles of classes of restricted words. Discret. Math. 310(23), 3303–3309 (2010)
Martin, M.H.: A problem in arrangements. Bull. Am. Math. Soc. 40(12), 859–864 (1934)
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)
Ruskey, F., Sawada, J., Williams, A.: Binary bubble languages and cool-lex Gray codes. J. Combin. Theory Ser. A 119(1), 155–169 (2012)
Ruskey, F., Sawada, J., Williams, A.: De Bruijn sequences for fixed-weight binary strings. SIAM J. Discret. Math. 26(2), 605–617 (2012)
Ruskey, F., Williams, A.: The coolest way to generate combinations. Discret. Math. 309(17), 5305–5320 (2009)
Ruskey, F., Williams, A.: An explicit universal cycle for the \((n-1)\)-permutations of an \(n\)-set. ACM Trans. Algorithm 6(3), 45 (2010)
Rytter, W., Zuba, W.: Syntactic view of sigma-tau generation of permutations. Theoret. Comput. Sci. 882, 49–62 (2021)
Sarbazi-Azad, H.: Stupid sort: A new sorting algorithm. Newsletter of Computing Science Department, Univ. of Glasgow Vol. 599, 4 (2000)
Sawada, J.: De Bruijn Sequence and Universal Cycle Constructions. http://debruijnsequence.org/. Accessed: 2021-12-31
Sawada, J.: A fast algorithm to generate necklaces with fixed content. Theoret. Comput. Sci. 301(1), 477–489 (2003)
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
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)
Sawada, J., Williams, A.: Solving the sigma-tau problem. ACM Trans. Algorithms 16(1), 1–17 (2019)
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)
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)
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)
Steinhaus, H.: One hundred problems in elementary mathematics. Courier Corporation, (1979)
Stevens, B., Williams, A.: Hamilton cycles in restricted and incomplete rotator graphs. J. Graph Algorithms Appl. 16(4), 785–810 (2012)
Swan, R.G.: A simple proof of rankin’s campanological theorem. Am. Math. Mon. 106(2), 159–161 (1999)
van Aardenne-Ehrenfest, T.: Circuits and trees in oriented linear graphs. Simon Stevin 28, 203–217 (1951)
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
Williams, A.: Shift Gray codes. PhD thesis, University of Victoria, (2009)
Williams, A.: The greedy gray code algorithm. In Workshop on Algorithms and Data Structures, pp 525–536. Springer, (2013)
Wong, D.: A new universal cycle for permutations. Graphs Combin. 33(6), 1393–1399 (2017)
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
Corresponding author
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)\)
Appendix B: Concatenation approach to construct the reverse of \(\mathcal {U}(S)\)
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.
About this article
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
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00453-022-01047-2