The sorted list of Lyndon words of length $5$ or $1$ is $$\mathcal{L}_5 = (\sa{0},\sa{00001},\sa{00011},\sa{00101},\sa{00111}, \sa{01011},\sa{01111},\sa{1})$$ and the concatenation of its words is $$\mathbf{b}_5 = \sa{0}\;\sa{00001}\;\sa{00011}\;\sa{00101}\;\sa{00111}\; \sa{01011}\;\sa{01111}\;\sa{1}.$$ It is the lexicographically smallest de Bruijn word of order $5$ and has length $32=2^5$.
Problem 18: From Lyndon Words to de Bruijn Words |
The combinatorial result of the problem provides the basis for an efficient online construction of de Bruijn words.
A binary word (on the alphabet $\{\sa{0},\sa{1}\}$) is a de Bruijn word of order (rank or span) $k$ if it contains cyclically each binary word of length $k$ exactly once as a factor. The word is of length $2^k$. There is a surprising relation between these words and the lexicographic ordering, which shows once more that ordering words is a powerful tool in text algorithms.
A Lyndon word is a primitive word that is the (lexicographically) smallest word in its conjugacy equivalence class.
Let $p$ be a prime number and $\mathcal{L}_p = (L_0,L_1,\dots,L_m)$ the sorted sequence of binary Lyndon words of length $p$ or $1$. Let also $$\mathbf{b}_p = L_0\cdot L_1\cdots L_m$$ be the concatenation of words in $\mathcal{L}_p$.