Necklaces and Lyndon words in colexicographic order

📅 2026-07-06
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the problem of efficiently enumerating all necklaces and Lyndon words of length \( n \) in colexicographic order over an arbitrary alphabet size. We present the first algorithm achieving constant amortized time per output, whose key innovation lies in introducing “quasi-necklaces”—a superset of necklaces that are easier to generate—and designing a traversal mechanism for them in colexicographic order. Theoretical analysis shows that the number of quasi-necklaces is linearly proportional to the number of necklaces, thereby guaranteeing the algorithm’s constant amortized complexity. This approach not only yields the first optimal enumeration in colexicographic order but also directly enables efficient generation of de Bruijn sequences and necklaces under weight constraints.
📝 Abstract
We present the first constant-amortized-time algorithms for generating all length-$n$ necklaces and Lyndon words over a $k$-letter alphabet in colexicographic order, for arbitrary $k\geq 2$. Our approach introduces a novel class of words called \emph{quasinecklaces}, which serve as an easily generated superset of necklaces through which all necklaces can be efficiently identified. We derive a formula for the number $Q_k(n)$ of length-$n$ quasinecklaces and show that $Q_k(n)$ is proportional to the number of length-$n$ necklaces, which is the key property needed to achieve constant amortized time. We also apply our results to efficiently generate a well-known de Bruijn sequence and efficiently generate necklaces and Lyndon words subject to a weight constraint.
Problem

Research questions and friction points this paper is trying to address.

necklaces
Lyndon words
colexicographic order
constant amortized time
combinatorial generation
Innovation

Methods, ideas, or system contributions that make the work stand out.

quasinecklaces
constant-amortized-time
colexicographic order
necklaces
Lyndon words
🔎 Similar Papers
No similar papers found.