January 25, 2024
An orientable sequence of order \(n\) is a cyclic binary sequence such that each length-\(n\) substring appears at most once in either direction. Maximal length orientable sequences are known only for \(n\leq 7\), and a trivial upper bound on their length is \(2^{n-1} - 2^{\lfloor(n-1)/2\rfloor}\). This paper presents the first efficient algorithm to construct orientable sequences that reach this upper bound, asymptotically; more specifically, our algorithm constructs orientable sequences via cycle-joining and a successor-rule approach requiring \(O(n)\) time per bit and \(O(n)\) space. This answers a longstanding open question from Dai, Martin, Robshaw, Wild [Cryptography and Coding III (1993)]. Applying a recent concatenation-tree framework, the same sequences can be generated in \(O(1)\)-amortized time per bit using \(O(n^2)\) space. Our sequences are applied to find new longest-known (aperiodic) orientable sequences for \(n\leq 20\).
Orientable sequences were introduced by Burns and Mitchell [1] and studied by Dai, Martin, Robshaw, and Wild [2] with applications related to robotic position sensing. In particular, consider an autonomous robot with limited sensors. To determine its location on a cyclic track labeled with black and white squares, the robot scans a window of \(n\) squares directly beneath it. For the position and orientation to be uniquely determined, the track must be designed with the property that each length \(n\) window can appear at most once in either direction. A cyclic binary sequence (track) with such a property is called an orientable sequence of order \(n\) (an \(\mathcal{OS}(n)\)). By this definition, an orientable sequence does not contain a length-\(n\) substring that is a palindrome.
Example
Consider \(\mathcal{S}=001011\). In the forward direction, including the wraparound, \(\mathcal{S}\) contains the six 5-tuples \(00101\), \(01011\), \(10110\), \(01100\), \(11001\), and \(10010\); in the reverse direction \(\mathcal{S}\) contains \(11010\), \(10100\), \(01001\), \(10011\), \(00110\), and \(01101\). Since each substring is unique, \(\mathcal{S}\) is an \(\mathcal{OS}(5)\) with length (period) six.
Orientable sequences do not exist for \(n=1\), and somewhat surprisingly, the maximum length \(M_n\) of an \(\mathcal{OS}(n)\) is known only for \(1 < n \leq 7\). Since the number of palindromes of length \(n\) is \(2^{\lfloor (n+1)/2\rfloor}\), a trivial upper bound on \(M_n\) is \((2^n - 2^{\lfloor (n+1)/2\rfloor})/2= 2^{n-1} - 2^{\lfloor(n-1)/2\rfloor}\).
In addition to providing a tighter upper bound, Dai, Martin, Robshaw, and Wild [2] provide a lower bound \(L_n\) on \(M_n\) by demonstrating the existence of \(\mathcal{OS}(n)\)s via cycle-joining with length \(L_n\) asymptotic to their upper bound. They conclude by stating the following open problem relating to orientable sequences whose lengths (periods) attain the lower bound. See Section 2.1 for the explicit upper and lower bounds.
We note that the lower bound on the maximum period was obtained using an existence construction … It is an open problem whether a more practical procedure exists for the construction of orientable sequences that have this asymptotically optimal period.
Recently, some progress was made in this direction by Mitchell and Wild [3]. They apply Lempel’s lift [4] to obtain an \(\mathcal{OS}(n)\) recursively from an \(\mathcal{OS}(n{-}1)\). This construction can generate orientable sequences in \(O(1)\)-amortized time per bit; however, it requires exponential space, and there is an exponential time delay before the first bit can be output. Furthermore, they state that their work “only partially answers the question, since the periods/lengths of the sequences produced are not asymptotically optimal.”
Main result: By developing a parent rule to define a cycle-joining tree, we construct an \(\mathcal{OS}(n)\) of length \(L_n\) in \(O(n)\) time per bit using \(O(n)\) space. Then, by applying the recent theory of concatenation trees [5], the same orientable sequences can be constructed in \(O(1)\)-amortized time per bit using \(O(n^2)\) space.
Outline. 1 In Section 2, we present necessary background definitions and notation, a review of the lower bound \(L_n\) and upper bound \(U_n\) from [2], and a review of the cycle-joining technique. In Section 3, we provide a parent rule for constructing a cycle-joining tree composed of “reverse-disjoint” cycles corresponding to asymmetric bracelets. This leads to our \(O(n)\) time per bit construction of orientable sequences of length \(L_n\). In Section 4, we present properties of the periodic nodes in our cycle-joining tree and in Section 5, we provide an algorithm for determining the children of a given node. In Section 6, we convert our cycle-joining trees to concatenation trees, which leads to a construction requiring \(O(1\))-amortized time per bit. In Section 7 we discuss the algorithmic techniques used to extend our constructed orientable sequences to find longer ones for \(n\leq 20\). Then in Section 8, we apply similar techniques to find some longest known acyclic orientable sequences for \(n\leq 20\). We conclude in Section 9 with a summary of our results and directions for future research. Implementations of our algorithms are available for download at http://debruijnsequence.org/db/orientable.
Recall the problem of determining a robot’s position and orientation on a track. Suppose now that we allow the track to be non-cyclic. That is, the beginning of the track and the end of the track are not connected. Then the corresponding sequence that allows one to determine orientation and position is called an acyclic orientable sequence. One does not consider the substrings in the wraparound for this variation of an orientable sequence. Note that one can always construct an acyclic \(\mathcal{OS}(n)\) from a cyclic \(\mathcal{OS}(n)\) by taking the cyclic \(\mathcal{OS}(n)\) and appending its prefix of length \(n{-}1\) to the end. See the paper by Burns and Mitchell [1] for more on acyclic orientable sequences, which they call aperiodic \(2\)-orientable window sequences. Alhakim et al. [7] generalize the recursive results of Mitchell and Wild [3] to construct orientable sequences over alphabets of size two or greater; they also generalize the upper bound, by Dai et al. [2], on the length of an orientable sequence. Rampersad and Shallit [8] showed that for every alphabet of size two or greater, there is an infinite sequence such that for every sufficiently long substring, the reversal of the substring does not appear in the sequence. Fleischer and Shallit [9] later reproved the results of the previous paper using theorem-proving software. See [10], [11] for more work on sequences avoiding reversals of substrings.
Let \(\mathbf{B}(n)\) denote the set of all length-\(n\) binary strings. Let \(\alpha = \mathtt{a}_1\mathtt{a}_2\cdots \mathtt{a}_n \in \mathbf{B}(n)\) and \(\beta = \mathtt{b}_1\mathtt{b}_2\cdots \mathtt{b}_m \in \mathbf{B}(m)\) for some \(m,n\geq 0\). Throughout this paper, we assume \(0<1\) and use lexicographic order when comparing two binary strings. More specifically, we say that \(\alpha < \beta\) either if \(\alpha\) is a prefix of \(\beta\) or if \(\mathtt{a}_i < \mathtt{b}_i\) for the smallest \(i\) such that \(\mathtt{a}_i \neq \mathtt{b}_i\). We say that \(\alpha\) is a rotation of \(\beta\) if \(m=n\) and there exist strings \(x\) and \(y\) such that \(\alpha = xy\) and \(\beta = yx\). The weight (density) of a binary string is the number of \(1\)s in the string. Let \(\overline{\mathtt{a}}_i\) denote the complement of bit \(\mathtt{a}_i\). Let \(\alpha^R\) denote the reversal \(\mathtt{a}_n\cdots \mathtt{a}_2\mathtt{a}_1\) of \(\alpha\); \(\alpha\) is a palindrome if \(\alpha = \alpha^R\). For \(j\geq 1\), let \(\alpha^j\) denote \(j\) copies of \(\alpha\) concatenated together. If \(\alpha = \gamma^j\) for some non-empty string \(\gamma\) and some \(j > 1\), then \(\alpha\) is said to be periodic2; otherwise, \(\alpha\) is said to be aperiodic (or primitive). Let \(\mathop{\mathrm{ap}}(\alpha)\) denote the shortest string \(\gamma\) such that \(\alpha = \gamma^t\) for some positive integer \(t\); we say \(\gamma\) is the aperiodic prefix of \(\alpha\). Observe that \(\alpha\) is aperiodic if and only if \(\mathop{\mathrm{ap}}(\alpha) = \alpha\).
A necklace class is an equivalence class of strings under rotation. Let \([\alpha]\) denote the set of strings in \(\alpha\)’s necklace class. We say \(\alpha\) is a necklace if it is the lexicographically smallest string in \([\alpha]\). Let \(\tilde{\alpha}\) denote the necklace in \([\alpha]\). Let \(\mathbf{N}(n)\) denote the set of length-\(n\) necklaces. A bracelet class is an equivalence class of strings under rotation and reversal; let \(\langle \alpha \rangle\) denote the set of strings in \(\alpha\)’s bracelet class. Thus, \(\langle \alpha \rangle = [\alpha] \cup [\alpha^R]\). We say \(\alpha\) is a bracelet if it is the lexicographically smallest string in \(\langle \alpha \rangle\). Note that in general, a bracelet is always a necklace, but a necklace need not be a bracelet. For example, the string \(001011\) is both a bracelet and a necklace, but the string \(001101\) is a necklace not a bracelet. A necklace \(\alpha\) is symmetric if it belongs to the same necklace class as \(\alpha^R\), i.e., both \(\alpha\) and \(\alpha^R\) belong to \([\alpha]\). By this definition, a symmetric necklace is necessarily a bracelet. If a necklace or bracelet is not symmetric, it is said to be asymmetric. Let \(\mathbf{A}(n)\) denote the set of all asymmetric bracelets of length \(n\). Table ¿tbl:tab:neck? lists all \(60\) necklaces of length \(n=9\) partitioned into asymmetric necklace pairs and symmetric necklaces. The asymmetric necklace pairs belong to the same bracelet class, and the first string in each pair is an asymmetric bracelet. Thus, \(|\mathbf{A}(9)| = 14\). In general, \(|\mathbf{A}(n)|\) is equal to the number of necklaces of length \(n\) minus the number of bracelets of length \(n\); for \(n=6, 7, \ldots 15\), this sequence of values \(|\mathbf{A}(n)|\) is given by \(1\), \(2\), \(6\), \(14\), \(30\), \(62\), \(128\), \(252\), \(495\), \(968\) and it corresponds to sequence A059076 in The On-Line Encyclopedia of Integer Sequences [12]. Asymmetric bracelets have been studied previously in the context of efficiently ranking/unranking bracelets [13].
Lemma 1. One can determine whether a string \(\alpha\) is in \(\mathbf{A}(n)\) in \(O(n)\) time using \(O(n)\) space.
Proof. A string \(\alpha\) will belong to \(\mathbf{A}(n)\) if \(\alpha\) is a necklace and the necklace of \([\alpha^R]\) is lexicographically larger than \(\alpha\). These tests can be computed in \(O(n)\) time using \(O(n)\) space [14]. ◻
ccmmccrcc cccclccc pccrc & Symmetric necklaces
, 000001101 & 000000000 000100011 001110111
, 000011001 & 000000001 000101101 001111111
, 000011101 & 000000011 000110011 010101011
, 000101001 & 000000101 000111111 010101111
, 000111001 & 000000111 001001001 010111111
, 000110101 & 000001001 001001111 011011011
, 000111101 & 000001111 001010011 011011111
, 000111011 & 000010001 001010101 011101111
, 001001101 & 000010101 001011101 011111111
, 001110101 & 000011011 001100111 111111111
, 001101101 & 000011111 001101011
, 001111101 &
, 001111011 &
, 010111011 &
Lemma 2 is considered a folklore result in combinatorics on words; see Theorem 4 in [15] for a variant of the lemma. We provide a short proof for the interested reader.
Lemma 2. A necklace \(\alpha\) is symmetric if and only if there exists palindromes \(\beta_1\) and \(\beta_2\) such that \(\alpha = \beta_1 \beta_2\).
Proof. Suppose \(\alpha\) is a symmetric necklace. By definition, it is equal to the necklace of \([\alpha^R]\). Thus, there exist strings \(\beta_1\) and \(\beta_2\) such that \(\alpha = \beta_1\beta_2 = (\beta_2\beta_1)^R = \beta_1^R\beta_2^R\). Therefore, \(\beta_1=\beta_1^R\) and \(\beta_2=\beta_2^R\), which means \(\beta_1\) and \(\beta_2\) are palindromes. Suppose there exists two palindromes \(\beta_1\) and \(\beta_2\) such that \(\alpha = \beta_1 \beta_2\). Since \(\beta_1\) and \(\beta_2\) are symmetric, we have that \(\alpha^R = (\beta_1\beta_2)^R = \beta_2^R\beta_1^R = \beta_2\beta_1\). So \(\alpha\) belongs to the same necklace class as \(\alpha^R\) and hence is symmetric. ◻
Corollary 1. If \(\alpha = 0^s\beta\) is a symmetric bracelet such that the string \(\beta\) begins and ends with \(1\) and does not contain \(0^s\) as a substring, then \(\beta\) is a palindrome.
Dai, Martin, Robshaw, and Wild [2] gave a lower bound \(L_n\) and an upper bound \(U_n\) on the maximum length \(M_n\) of an \(\mathcal{OS}(n)\).3 The lower bound \(L_n\) corresponds to the length of the sequence that results from joining all asymmetric necklaces in a specific way. Their lower bound \(L_n\) is the following, where \(\mu\) is the Möbius function: \[\label{eqn:L} L_n =\sum_{\alpha \in \mathbf{A}(n)}|\mathop{\mathrm{ap}}(\alpha)| = \left( 2^{n-1} - \frac{1}{2} \sum_{d | n} \mu(n/d) \frac{n}{d} H(d) \right), \;\;\text{ where } \;\;H(d) = \frac{1}{2} \sum\limits_{i | d} i \left( 2^{\lfloor \frac{i+1}{2} \rfloor} + 2^{\lfloor \frac{i}{2} \rfloor +1} \right).\tag{1}\]
Their upper bound \(U_n\) is the following:\(^{\ref{note1}}\)
\(U_n= \left\{ \begin{array}{ll} 2^{n-1} - \frac{41}{9}2^{\frac{n}{2}-1} + \frac{n}{3} + \frac{16}{9}, \; &\;\; if n \bmod 4 = 0;\\ 2^{n-1} - \frac{31}{9}2^{\frac{n-1}{2}} + \frac{n}{3} + \frac{19}{9}, \; &\;\; if n \bmod 4 = 1;\\ 2^{n-1} - \frac{41}{9}2^{\frac{n}{2}-1} + \frac{n}{6} + \frac{20}{9}, \; &\;\; if n \bmod 4 = 2;\\ 2^{n-1} - \frac{31}{9}2^{\frac{n-1}{2}} + \frac{n}{6} + \frac{43}{18}, \; &\;\; if n \bmod 4 = 3.\\ \end{array} \right.\)
These bounds are calculated in Table ¿tbl:table:bounds? for \(n\) up to 20. This table also illustrates the length \(R_n\) of the \(\mathcal{OS}(n)\) produced by the recursive construction by Mitchell and Wild [3], starting from an initial orientable sequence of length 80 for \(n=8\). The column labeled \(L^*_n\) indicates the longest known orientable sequences we discovered by applying a combination of techniques (discussed in Section 7) to our orientable sequences of length \(L_n\).
| \(n\) | \(R_n\) | \(L_n\) | \(L^{*}_n\) | \(U_n\) |
|---|---|---|---|---|
| 5 | - | 0 | 6 | |
| 6 | - | 6 | 17 | |
| 7 | - | 14 | 40 | |
| 8 | 80 | 48 | 96 | |
| 9 | 161 | 126 | 206 | |
| 10 | 322 | 300 | 443 | |
| 11 | 645 | 682 | 918 | |
| 12 | 1290 | 1530 | 1908 | |
| 13 | 2581 | 3276 | 3882 | |
| 14 | 5162 | 6916 | 7905 | |
| 15 | 10325 | 14520 | 15948 | |
| 16 | 20650 | 29808 | 32192 | |
| 17 | 41301 | 61200 | 64662 | |
| 18 | 82602 | 124368 | 129911 | |
| 19 | 165205 | 252434 | 260386 | |
| 20 | 330410 | 509220 | 521964 |
Given \(\mathbf{S}\subseteq \mathbf{B}(n)\), a universal cycle \(U\) for \(\mathbf{S}\) is a cyclic sequence of length \(|\mathbf{S}|\) that contains each string in \(\mathbf{S}\) as a substring (exactly once). Thus, an orientable sequence is a universal cycle. If \(\mathbf{S}= \mathbf{B}(n)\) then \(U\) is known as a de Bruijn sequence. Given a universal cycle \(U\) for \(\mathbf{S}\), a successor rule for \(U\) is a function \(f:\mathbf{S}\rightarrow \{0,1\}\) such that \(f(\alpha)\) is the bit following \(\alpha\) in \(U\).
Cycle-joining is perhaps the most fundamental technique applied to construct universal cycles. For instance, see [2]. If \(\mathbf{S}\) is closed under rotation, then it can be partitioned into necklace classes (cycles); each cycle is disjoint. Let \(\alpha = \mathtt{a}_1\mathtt{a}_2\cdots \mathtt{a}_n\) and \(\hat{\alpha} = \mathtt{\overline{a}}_1\mathtt{a}_2\cdots \mathtt{a}_n\); we say \((\alpha, \hat{\alpha})\) is a conjugate pair. Two disjoint cycles can be joined if they each contain one string of a conjugate pair as a substring. This approach resembles pioneering algorithm of Hierholzer (1873) to construct an Euler cycle in an Eulerian graph.
Example
Consider disjoint subsets \(\mathbf{S}_1 = [011111] \cup [001111]\) and \(\mathbf{S}_2 = [010111] \cup [010101]\), where \(n=6\). Then \(U_1 = 110011\underline{110111}\) is a universal cycle for \(\mathbf{S}_1\) and \(U_2 = 01\underline{010111}\) is a universal cycle for \(\mathbf{S}_2\). Since \((110111,010111)\) is a conjugate pair, \(U = 110011\underline{110111}01\underline{010111}\) is a universal cycle for \(\mathbf{S}_1 \cup \mathbf{S}_2\).
A cycle-joining tree is a tree with nodes representing disjoint universal cycles; an edge between two nodes implies they each contain one string of a conjugate pair. If \(\mathbf{S}\) is the set of all length-\(n\) strings belonging to the disjoint cycles of a cycle-joining tree, then the tree defines a universal \(U\) for \(\mathbf{S}\) along with a corresponding successor rule; see Section 3 for an example. For most universal cycle constructions, a corresponding cycle-joining tree can be defined by a rather simple parent rule. For example, when \(\mathbf{S}= \mathbf{B}(n)\), the following are perhaps the simplest parent rules that define how to construct cycle-joining trees with nodes corresponding to necklace cycles represented by \(\mathbf{N}(n)\) [5], [16], [17].
Last-\(0\): rooted at \(1^n\) and the parent of every other node \(\alpha \in \mathbf{N}(n)\) is obtained by flipping the last \(0\).
First-\(1\): rooted at \(0^n\) and the parent of every other node \(\alpha \in \mathbf{N}(n)\) is obtained by flipping the first \(1\).
Last-\(1\): rooted at \(0^n\) and the parent of every other node \(\alpha \in \mathbf{N}(n)\) is obtained by flipping the last \(1\).
First-\(0\): rooted at \(1^n\) and the parent of every other node \(\alpha \in \mathbf{N}(n)\) is obtained by flipping the first \(0\).
These rules induce the cycle-joining trees \(\mathrm{T}_1\), \(\mathrm{T}_2\), \(\mathrm{T}_3\), \(\mathrm{T}_4\) illustrated in Figure 1 for \(n=6\). Note that for \(\mathrm{T}_3\) and \(\mathrm{T}_4\), the parent of a node \(\alpha\) is obtained by first flipping the highlighted bit and then rotating the string to its lexicographically least rotation to obtain a necklace. Each node \(\alpha\) and its parent \(\beta\) are joined by a conjugate pair, where the highlighted bit in \(\alpha\) is the first bit in one of the conjugates. For example, the nodes \(\alpha = 0{\boldsymbol{\textcolor{red}}{1}}1011\) and \(\beta = 001011\) in \(\mathrm{T}_2\) from Figure 1 are joined by the conjugate pair \(({\boldsymbol{\textcolor{red}}{1}}10110, 010110)\).

Figure 1: Cycle-joining trees for \(\mathbf{B}(6)\) from simple parent rules..
Consider the set of asymmetric bracelets \(\mathbf{A}(n) = \{\alpha_1, \alpha_2, \ldots, \alpha_t\}\). Recall, that each symmetric bracelet is a necklace. Let \(\mathbf{S}(n) = [\alpha_1] \cup [\alpha_2] \cup \cdots \cup [ \alpha_t ]\). From [2], we have \(|\mathbf{S}(n)| = L_n\). By definition, there is no string \(\alpha \in \mathbf{S}(n)\) such that \(\alpha^R \in \mathbf{S}(n)\). Thus, a universal cycle for \(\mathbf{S}(n)\) is an \(\mathcal{OS}(n)\). To construct a cycle-joining tree with nodes \(\mathbf{A}(n)\), we apply a combination of three of the four simple parent rules described in the previous section. First, we demonstrate that there is no such parent rule using at most two rules in combination. Assume \(n \geq 8\). Observe that none of the necklaces in \(\mathbf{A}(n)\) have weight \(0\), \(1\), \(2\), \(n{-}2\), \(n{-}1\), or, \(n\). Thus, \(0^{n-4}1011\) and \(0^{n-5}10011\) are both necklaces in \(\mathbf{A}(n)\) with minimal weight three. Similarly, \(00101^{n-4}\) and \(001101^{n-5}\) are necklaces in \(\mathbf{A}(n)\) with maximal weight \(n{-}3\). Therefore, when considering a parent rule for a cycle-joining tree with nodes \(\mathbf{A}(n)\), the rule must be able to flip a \(0\) to a \(1\), or a \(1\) to a \(0\), i.e., if the rule applies a combination of the four rules from Section 2.2, it must include one of First-\(0\) or Last-\(0\), and one of First-\(1\) and Last-\(1\).
Let \(\alpha = \mathtt{a}_1\mathtt{a}_2\cdots \mathtt{a}_n\) denote a necklace in \(\mathbf{A}(n)\); it must begin with \(0\) and end with \(1\). Then let
\(\mathop{\mathrm{first1}}(\alpha)\) be the necklace \(\mathtt{a}_1\cdots\mathtt{a}_{i-1}{\boldsymbol{\textcolor{blue}}{0}}\mathtt{a}_{i+1}\cdots \mathtt{a}_n\), where \(i\) is the index of the first \(1\) in \(\alpha\);
\(\mathop{\mathrm{last1}}(\alpha)\) be the necklace of \([\mathtt{a}_1\mathtt{a}_2 \cdots \mathtt{a}_{n-1}{\boldsymbol{\textcolor{blue}}{0}}]\);
\(\mathop{\mathrm{first0}}(\alpha)\) be the necklace of \([{\boldsymbol{\textcolor{red}}{1}}\mathtt{a}_2 \cdots \mathtt{a}_{n}]\);
\(\mathop{\mathrm{last0}}(\alpha)\) be the necklace \(\mathtt{a}_1\cdots\mathtt{a}_{j-1}{\boldsymbol{\textcolor{red}}{1}}\mathtt{a}_{j+1}\cdots \mathtt{a}_n\), where \(j\) is the index of the last \(0\) in \(\alpha\).
Note that \(\mathop{\mathrm{first1}}(\alpha)\) and \(\mathop{\mathrm{last0}}(\alpha)\) are necklaces (easily observed by definition) obtained by flipping the \(i\)-th and \(j\)-th bit in \(\alpha\), respectively; \(\mathop{\mathrm{last1}}(\alpha)\) and \(\mathop{\mathrm{first0}}(\alpha)\) are the result of flipping a bit and rotating the resulting string to obtain a necklace. The following remark follows from the definition of necklace.
Let \(\alpha=\beta 10^t1\) be a necklace where \(\beta\) is some string, and \(t \geq 0\). Then \(\mathop{\mathrm{last1}}(\alpha) = 0^{t+1}\beta1\).
Proposition [prop:2rules] illustrates that for \(n\) sufficiently large, no two of the above four parent rules can be applied in combination to obtain a cycle-joining tree with nodes \(\mathbf{A}(n)\).
Let \(\mathrm{p}\) be a parent rule that applies some combination of \(\mathop{\mathrm{first1}}\), \(\mathop{\mathrm{last1}}\), \(\mathop{\mathrm{first0}}\), and \(\mathop{\mathrm{last0}}\) to construct a cycle-joining tree with nodes \(\mathbf{A}(n)\). Then \(\mathrm{p}\) must apply at least three of these rules for all \(n\geq 10\).
Proof. Suppose \(n\geq 10\). By our earlier observation, any parent rule for a cycle-joining tree with nodes \(\mathbf{A}(n)\) must be able to flip a \(0\) to a \(1\), and a \(1\) to a \(0\). Therefore, \(\mathrm{p}\) must include one of \(\mathop{\mathrm{first0}}\) or \(\mathop{\mathrm{last0}}\), and one of \(\mathop{\mathrm{first1}}\) and \(\mathop{\mathrm{last1}}\).
Suppose \(\mathrm{p}\) does not apply \(\mathop{\mathrm{first0}}\). Then it must apply \(\mathop{\mathrm{last0}}\). Consider three asymmetric bracelets in \(\mathbf{A}(n)\): \(\alpha_1 = 0^{n-4}1011\), \(\alpha_2 = 0^{n-5}10111\), and \(\alpha_3 = 0^{n-6}110111\). Clearly, \(\mathop{\mathrm{first1}}(\alpha_1)=0^{n-2}11\), \(\mathop{\mathrm{last1}}(\alpha_1)=0^{n-3}101\), and \(\mathop{\mathrm{last0}}(\alpha_1)=0^{n-4}1111\) are symmetric. Thus, \(\alpha_1\) must be the root. Both \(\mathop{\mathrm{first1}}(\alpha_2)=0^{n-3}111\) and \(\mathop{\mathrm{last0}}(\alpha_2)=0^{n-5}11111\) are symmetric, so \(\mathrm{p}\) must apply \(\mathop{\mathrm{last1}}\). Both \(\mathop{\mathrm{last0}}(\alpha_3)=0^{n-6}111111\) and \(\mathop{\mathrm{last1}}(\alpha_3)=0^{n-5}11011\) are symmetric, so \(\mathrm{p}\) must apply \(\mathop{\mathrm{first1}}\).
Suppose \(\mathrm{p}\) does not apply \(\mathop{\mathrm{last0}}\). Then it must apply \(\mathop{\mathrm{first0}}\). Let \(m = 0\) if \(n\) is even, and \(m=1\) otherwise. Let \(\ell = (n-6-m)/2\). Note that \(\ell \geq 2\) for \(n\geq 10\). Consider three asymmetric bracelets in \(\mathbf{A}(n)\): \(\beta_1 = 00101^{n-7}011\), \(\beta_2 = 00101^{n-4}\), and \(\beta_3 = 0^{\ell+1}10^{m+1}10^\ell11\). Clearly, \(\mathop{\mathrm{last1}}(\beta_1)=000101^{n-7}01\) is symmetric and \(\mathop{\mathrm{first1}}(\beta_1)=00001^{n-7}011\) is not a bracelet. Additionally, \(\mathop{\mathrm{first0}}(\beta_1)=0101^{n-7}0111\) is symmetric when \(n=10\) and is not a bracelet for all \(n>10\). Thus, \(\beta_1\) must be the root. Both \(\mathop{\mathrm{first1}}(\beta_2)=00001^{n-4}\) and \(\mathop{\mathrm{first0}}(\beta_2)=0101^{n-3}\) are symmetric, so \(\mathrm{p}\) must apply \(\mathop{\mathrm{last1}}\). Now for \(\beta_3\), we have that \(\mathop{\mathrm{first0}}(\beta_3)=0^{\ell}10^{m+1}10^\ell 111\) is symmetric. We also have that \(\mathop{\mathrm{last1}}(\beta_3)=0^{\ell+2}10^{m+1}10^\ell1\) is symmetric when \(n=11\) and is not a bracelet when \(n=10\) or \(n>11\). Thus, \(\mathrm{p}\) must apply \(\mathop{\mathrm{first1}}\). ◻
For \(n \geq 6\), we choose the lexicographically smallest length-\(n\) asymmetric bracelet \(\mathit{r}_n=0^{n-4}1011\) to be the root of our cycle-joining tree.
Parent rule for cycle-joining \(\mathbf{A}(n)\): Let \(\mathit{r}_n\) be the root. Let \(\alpha\) denote a non-root node in \(\mathbf{A}(n)\). Then
\[\label{eq:par} \mathop{\mathrm{par}}(\alpha) = \left\{ \begin{array}{ll} \mathop{\mathrm{first1}}(\alpha) & \;\;if \mathop{\mathrm{first1}}(\alpha) \in \mathbf{A}(n);\\ \mathop{\mathrm{last1}}(\alpha) & \;\; if \mathop{\mathrm{first1}}(\alpha) \notin \mathbf{A}(n) and \mathop{\mathrm{last1}}(\alpha) \in \mathbf{A}(n); \\ \mathop{\mathrm{last0}}(\alpha) \; &\;\; otherwise.\end{array} \right.\tag{2}\]
Theorem 1. For \(n \geq 6\), the parent rule \(\mathop{\mathrm{par}}(\alpha)\) in (2 )* induces a cycle-joining tree with nodes \(\mathbf{A}(n)\) rooted at \(\mathit{r}_n\). The tree has height less than \(2(n-4)\).*
Let \(\mathbb{T}_n\) denote the cycle-joining tree with nodes \(\mathbf{A}(n)\) induced by the parent rule in (2 ); Figure 2 illustrates \(\mathbb{T}_9\). The proof of Theorem 1 relies on the following lemma.

Figure 2: The cycle-joining tree \(\mathbb{T}_9\). The black edges indicate that \(\mathop{\mathrm{par}}(\alpha) = \mathop{\mathrm{first1}}(\alpha)\); the blue edges indicate that \(\mathop{\mathrm{par}}(\alpha) = \mathop{\mathrm{last1}}(\alpha)\); the red edges indicate that \(\mathop{\mathrm{par}}(\alpha) = \mathop{\mathrm{last0}}(\alpha)\)..
Lemma 3. Let \(\alpha \neq \mathit{r}_n\) be an asymmetric bracelet in \(\mathbf{A}(n)\). If neither \(\mathop{\mathrm{first1}}(\alpha)\) nor \(\mathop{\mathrm{last1}}(\alpha)\) are in \(\mathbf{A}(n)\), then the last \(0\) in \(\alpha\) is at index \(n{-}2\) or \(n{-}1\), and both \(\mathop{\mathrm{last0}}(\alpha)\) and \(\mathop{\mathrm{last1}}(\mathop{\mathrm{last0}}(\alpha))\) are in \(\mathbf{A}(n)\).
Proof. Since \(\alpha\) is an asymmetric bracelet, it must have the form \(\alpha = 0^i1\beta 01^j\) where \(i,j \geq 1\) and \(\beta 0\) does not contain \(0^{i+1}\) as a substring. Furthermore, \(1\beta 01^j < (1 \beta01^j)^R\), which implies \(\beta 01^{j-1} < (\beta 01^{j-1})^R\).
Suppose \(j > 2\). Since \(\mathop{\mathrm{last1}}(\alpha) = 0^{i+1}1 \beta 01^{j-1}\) is not an asymmetric bracelet, we have \(1 \beta 01^{j-1} \geq (1 \beta 01^{j-1})^R\). Thus, \(\beta\) begins with \(1\). Since \(\mathop{\mathrm{first1}}(\alpha) = 0^{i+1}\beta 01^j\) is not an asymmetric bracelet, Lemma 2 implies \(\beta 01^j \geq (\beta 01^j)^R\), contradicting the earlier observation that \(\beta 01^{j-1} < (\beta 01^{j-1})^R\). Thus, the last \(0\) in \(\alpha\) is at index \(n{-}2\) or \(n{-}1\).
Suppose \(j=1\) or \(j=2\). Then the last \(0\) in \(\alpha\) must be at position \(n{-}2\) or \(n{-}1\). Write \(\alpha = x0y\) where \(y=1\) or \(y=11\). Since \(\alpha\) is a bracelet, it is straightforward to see that \(\mathop{\mathrm{last0}}(\alpha)=x1y\) is also a bracelet. If it is symmetric, Lemma 2 implies there exist palindromes \(\beta_1\) and \(\beta_2\) such that \(\mathop{\mathrm{last0}}(\alpha)=x1y=\beta_1\beta_2\). However, flipping the \(1\) in \(x1y\) that allows us to obtain \(\alpha\) implies that \(\alpha\) is greater than or equal to the necklace in \([\alpha^R]\), contradicting the assumption that \(\alpha\) is an asymmetric bracelet. Thus, \(\mathop{\mathrm{last0}}(\alpha)\) is an asymmetric bracelet.
Consider \(\mathop{\mathrm{last1}}(\mathop{\mathrm{last0}}(\alpha)) = 0^{i+1}1\beta 1^j\). Let \(\beta = \mathtt{b}_1\mathtt{b}_2\cdots \mathtt{b}_m\). Suppose that \(m=0\). Then \(\mathop{\mathrm{last1}}(\mathop{\mathrm{last0}}(\alpha)) = 0^{i+1} 1^{j+1} \Rightarrow \mathop{\mathrm{last0}}(\alpha) = 0^{i}1^{j+2}\). Since \(j=1\) or \(j=2\), we have that \(\mathop{\mathrm{last0}}(\alpha) = 0^i 111\) or \(\mathop{\mathrm{last0}}(\alpha) = 0^i1111\). Now \(\alpha\) is the result of flipping one of the \(1\)s in \(\mathop{\mathrm{last0}}(\alpha)\) to a \(0\) and performing the appropriate rotation. But in every case, we end up with \(\alpha\) being a symmetric necklace, a contradiction. Thus, assume \(m \geq 1\). Suppose \(\beta = 1^m\). Then, \(\alpha\) is not an asymmetric bracelet, a contradiction. Suppose \(\beta = 0^m\). If \(j=1\), then \(\alpha\) is symmetric, a contradiction; if \(j=2\), then \(\mathop{\mathrm{last1}}(\mathop{\mathrm{last0}}(\alpha)) = 0^{i+1}10^{m}11\) which is in \(\mathbf{A}(n)\). For all other cases, \(\beta\) contains at least one \(1\) and at least one \(0\); \(m \geq 2\). Since \(\beta\) does not contain \(0^{i+1}\) as a substring, by Lemma 2, we must show that (i) \(\beta 1^{j-1}\) is less than its reversal \(1^{j-1} \beta^R\), recalling that (ii) \(\beta 01^{j-1}\) is less than its reversal \(1^{j-1}0\beta^R\). Let \(\ell\) be the largest index of \(\beta\) such that \(\mathtt{b}_{\ell} = 1\). Then \(\mathtt{b}_{\ell+1}\cdots \mathtt{b}_m=0^{m-\ell}\); note that \(\mathtt{b}_{\ell+1}\cdots \mathtt{b}_m\) is the empty string when \(\ell=m\). Suppose \(j=1\). From (ii), we have \(\mathtt{b}_1 = 0\) and \(\mathtt{b}_2\cdots \mathtt{b}_{\ell-1} 1 0^{m-\ell} < 0^{m-\ell}1 \mathtt{b}_{\ell-1}\cdots \mathtt{b}_2\). But this implies that \(\mathtt{b}_2\cdots \mathtt{b}_{m-\ell+1} = 0^{m-\ell}\). Therefore, we have \(\beta = 0^{m-\ell+1} \mathtt{b}_{m-\ell+2} \cdots \mathtt{b}_m < 0^{m-\ell}1\mathtt{b}_{\ell-1}\cdots \mathtt{b}_1 = \beta^R\), hence (i) is satisfied. Suppose \(j=2\). If \(\mathtt{b}_1 = 0\), then (i) is satisfied. Otherwise \(\mathtt{b}_1=1\) and from (ii) \(\mathtt{b}_2=0\). From (ii), we get that \(\mathtt{b}_3 \cdots \mathtt{b}_{\ell-1}1 0^{m-\ell} < 0^{m-\ell}\mathtt{b}_{\ell-1}\cdots \mathtt{b}_3\). This inequality implies that \(\mathtt{b}_3 \cdots \mathtt{b}_{m-\ell+2} = 0^{m-\ell}\). Therefore, we have \(\beta 1 = 10^{m-\ell+1} \mathtt{b}_{m-\ell+3}\cdots \mathtt{b}_m1 < 10^{m-\ell} 1\mathtt{b}_{\ell-1}\cdots \mathtt{b}_1 = 1\beta^R\), hence (i) is satisfied. Thus, \(\mathop{\mathrm{last1}}(\mathop{\mathrm{last0}}(\alpha))\) is an asymmetric bracelet. ◻
Proof of Theorem 1. Let \(\alpha\) be an asymmetric bracelet in \(\mathbf{A}(n) \setminus \{\mathit{r}_n\}\). We can write \(\alpha\) as \(0^i1\beta\) for some string \(\beta\) and \(i \geq 1\). We demonstrate that the parent rule \(\mathop{\mathrm{par}}\) from (2 ) induces a path from \(\alpha\) to \(\mathit{r}_n\), i.e., there exists an integer \(j\) such that \(\mathop{\mathrm{par}}^j(\alpha) = \mathit{r}_n\). Note that \(\mathit{r}_n\) is the unique asymmetric bracelet with prefix \(0^{n-4}\). By Lemma 3, \(\mathop{\mathrm{par}}(\alpha) \in \mathbf{A}(n)\). In the first two cases of the parent rule, \(\mathop{\mathrm{par}}(\alpha)\) will have prefix \(0^{i+1}\). If the third case applies, Lemma 3 states that \(\mathop{\mathrm{last1}}( \mathop{\mathrm{last0}}(\alpha))\) is an asymmetric bracelet. Thus, \(\mathop{\mathrm{par}}(\mathop{\mathrm{par}}(\alpha))\) is either \(\mathop{\mathrm{first1}}( \mathop{\mathrm{last0}}(\alpha))\) or \(\mathop{\mathrm{last1}}( \mathop{\mathrm{last0}}(\alpha))\); in each case the resulting asymmetric bracelet has prefix \(0^{i+1}\). Since either \(\mathop{\mathrm{par}}(\alpha)\) or \(\mathop{\mathrm{par}}(\mathop{\mathrm{par}}(\alpha))\) has prefix \(0^{i+1}\), the parent rule induces a path from \(\alpha\) to \(\mathit{r}_n\) and the height of the resulting tree is at most \(2(n-4)-1\).
Each application of the parent rule \(\mathop{\mathrm{par}}(\alpha)\) in (2 ) corresponds to a conjugate pair. For instance, consider the asymmetric bracelet \(\alpha = 00010111{\boldsymbol{\textcolor{blue}}{1}}\). The parent of \(\alpha\) is obtained by flipping the last \(1\) to obtain \(00010111{\boldsymbol{\textcolor{blue}}{0}}\) (see Figure 2). The corresponding conjugate pair is \(({\boldsymbol{\textcolor{blue}}{1}}00010111, {\boldsymbol{\textcolor{blue}}{0}}00010111)\). Let \(\mathbf{C}(n)\) denote the set of all strings belonging to a conjugate pair in the cycle-joining tree \(\mathbb{T}_n\). Then the following is a successor rule for an \(\mathcal{OS}(n)\), given \(\alpha = \mathtt{a}_1\mathtt{a}_2\cdots \mathtt{a}_n \in \mathbf{S}(n)\): \[f(\alpha) = \left\{ \begin{array}{ll} \overline{\mathtt{a}}_1 & \;\;if \mathtt{a}_1\mathtt{a}_2\cdots \mathtt{a}_n \in \mathbf{C}(n);\\ {\mathtt{a}_1} \; &\;\; otherwise.\end{array} \right.\] For example, if \(\mathbf{C}(9)\) corresponds to the conjugate pairs to create the cycle-joining tree \(\mathbb{T}_9\) shown in Figure 2, then the corresponding universal cycle is:
| \(0\underline{{\boldsymbol{\textcolor{blue}}{0}}0001011 11}1001011 011001011 110011011 1\underline{{\boldsymbol{\textcolor{blue}}{1}}0001011 1}00101011 100011011\) |
| \(101011011 100001001 110001001 010001001 100001011 001001011 000101011,\) |
where the two underlined strings belong to the conjugate pair \(({\boldsymbol{\textcolor{blue}}{1}}00010111, {\boldsymbol{\textcolor{blue}}{0}}00010111)\). In general, this rule requires exponential space to store the set \(\mathbf{C}(n)\). However, in some cases, it is possible to test whether a string is in \(\mathbf{C}(n)\) without pre-computing and storing \(\mathbf{C}(n)\). In our successor rule for an \(\mathcal{OS}(n)\), we use Lemma 1 to avoid pre-computing and storing \(\mathbf{C}(n)\), thereby reducing the space requirement from exponential in \(n\) to linear in \(n\).
Successor-rule \(g\) to construct an \(\mathcal{OS}(n)\) of length \(L_n\)
Let \(\alpha = \mathtt{a}_1\mathtt{a}_2\cdots \mathtt{a}_n \in \mathbf{S}(n)\) and let
\(\beta_1 = 0^{n-i}\mathbf{1}\mathtt{a}_2\cdots \mathtt{a}_i\) where \(i\) is the largest index of \(\alpha\) such that \(\mathtt{a}_i = 1\) (First-\(1\));
\(\beta_2 = \mathtt{a}_2\mathtt{a}_3\cdots \mathtt{a}_n{\boldsymbol{\textcolor{blue}}{1}}\) (Last-\(1\));
\(\beta_3 = \mathtt{a}_j\mathtt{a}_{j+1}\cdots \mathtt{a}_n {\boldsymbol{\textcolor{red}}{0}} 1^{j-2}\) where \(j\) is the smallest index of \(\alpha\) such that \(\mathtt{a}_j = 0\) and \(j > 1\) (Last-\(0\)).
Let
\(g(\alpha) = \left\{ \begin{array}{ll} \overline{\mathtt{a}}_1 & \;\;if \beta_1 and \mathop{\mathrm{first1}}(\beta_1) are in \mathbf{A}(n);\\ \overline{\mathtt{a}}_1 &\;\; if \beta_2 and \mathop{\mathrm{last1}}(\beta_2) are in \mathbf{A}(n), and \mathop{\mathrm{first1}}(\beta_2) is not in \mathbf{A}(n);\\ \overline{\mathtt{a}}_1 &\;\; if \beta_3 and \mathop{\mathrm{last0}}(\beta_3) are in \mathbf{A}(n), and neither \mathop{\mathrm{first1}}(\beta_3) nor \mathop{\mathrm{last1}}(\beta_3) are in \mathbf{A}(n);\\ {\mathtt{a}_1} \; &\;\; otherwise.\end{array} \right.\)
Starting with any string in \(\alpha \in \mathbf{S}(n)\), we can repeatedly apply \(g(\alpha)\) to obtain the next bit in a universal cycle for \(\mathbf{S}(n)\).
Example
The following orientable sequences for \(n=6,7,8\) with lengths 6, 14, and 48 respectively are generated by applying the successor rule \(g\):
\(n=6\): \(001011\),
\(n=7\): \(00010111001011\), and
\(n=8\): \(000010111100101110011011100010011000101100101011\).
Theorem 2. For \(n \geq 6\), the function \(g\) is a successor rule that generates an \(\mathcal{OS}(n)\) with length \(L_n\) for the set \(\mathbf{S}(n)\) in \(O(n)\)-time per bit using \(O(n)\) space.
Proof. Consider \(\alpha = \mathtt{a}_1\mathtt{a}_2\cdots \mathtt{a}_n \in \mathbf{S}(n)\). If \(\alpha\) belongs to some conjugate pair in \(\mathbb{T}_n\), then it must satisfy one of three possibilities stepping through the parent rule in 2 :
Both \(\beta_1\) and \(\mathop{\mathrm{first1}}(\beta_1)\) must be in \(\mathbf{A}(n)\). Note, \(\beta_1\) is a rotation of \(\alpha\) when \(\mathtt{a}_1=1\), where \(\mathtt{a}_1\) corresponds to the first one in \(\beta_1\).
Both \(\beta_2\) and \(\mathop{\mathrm{last1}}(\beta_2)\) must both be in \(\mathbf{A}(n)\), but additionally, \(\mathop{\mathrm{first1}}(\beta_2)\) can not be in \(\mathbf{A}(n)\). Note, \(\beta_2\) is a rotation of \(\alpha\) when \(\mathtt{a}_1=1\), where \(\mathtt{a}_1\) corresponds to the last one in \(\beta_2\).
Both \(\beta_3\) and \(\mathop{\mathrm{last0}}(\beta_3)\) must both be in \(\mathbf{A}(n)\), but additionally, both \(\mathop{\mathrm{first1}}(\beta_3)\) and \(\mathop{\mathrm{last1}}(\beta_3)\) can not be in \(\mathbf{A}(n)\). Note, \(\beta_3\) is a rotation of \(\alpha\) when \(\mathtt{a}_1=0\), where \(\mathtt{a}_1\) corresponds to the last zero in \(\beta_3\).
Thus, \(g\) is a successor rule on \(\mathbf{S}(n)\) that generates a cycle of length \(|\mathbf{S}(n)| = L_n\). By Lemma 1, one can determine whether a string is in \(\mathbf{A}(n)\) in \(O(n)\) time using \(O(n)\) space. Since there are a constant number of tests required by each case of \(g\), the corresponding \(\mathcal{OS}(n)\) can be computed in \(O(n)\)-time per bit using \(O(n)\) space. ◻
In this section, we present several results on periodic nodes in \(\mathbb{T}_n\), assuming \(n \geq 6\).
Lemma 4. If a node \(\alpha \in \mathbf{A}(n)\) from the cycle-joining tree \(\mathbb{T}_n\) is periodic, it has no children.
Proof. Let \(\alpha\) be a non-root node \(\mathbf{A}(n)\). We demonstrate that \(\mathop{\mathrm{par}}(\alpha)\) is aperiodic, which implies the periodic nodes in \(\mathbb{T}_n\) have no children. Let \(j\) denote the index of the first \(1\) in \(\alpha\). Then \(\alpha\) has prefix \(0^{j-1}\) and no substring \(0^j\). Consider the three possibilities for \(\mathop{\mathrm{par}}(\alpha)\). Suppose \(\mathop{\mathrm{first1}}(\alpha)\) is in \(\mathbf{A}(n)\). Then it has prefix \(0^j\) and is aperiodic since there is no substring \(0^j\) not in the initial prefix of \(0\)s. Similarly, if \(\mathop{\mathrm{last1}}(\alpha)\) is in \(\mathbf{A}(n)\), then it has prefix \(0^j\) and is aperiodic since it also has no substring \(0^j\) not in the initial prefix of \(0\)s. Suppose \(\mathop{\mathrm{last0}}(\alpha)\) is in \(\mathbf{A}(n)\) and is periodic. Then we can write \(\mathop{\mathrm{last0}}(\alpha) = \beta^{k}\) where \(k>1\) and \(\beta\) is some string that contains a \(1\). Either \(\beta\) contains a \(0\), or it does not. If \(\beta\) does not contain a \(0\), then \(\beta = 1^i\) for some \(i\geq 1\). But this implies \(\alpha = 01^{n-1}\), which is not an asymmetric bracelet, a contradiction. Suppose \(\beta\) contains at least one \(0\). Write \(\alpha = uv = yx\) where \(u\), \(v\), \(x\), \(y\) are nonempty strings such that \(|u|=|x| = |\beta|\). Since \(\beta\) contains at least one \(0\), the last \(0\) in \(\alpha\) must occur in \(x\) and we must have \(u=\beta\). Thus, one can obtain \(x\) from \(\beta\) by flipping a single \(1\) to a \(0\), which implies \(x < \beta\). So we have \(xy < \beta v = uv = yx= \alpha\), which contradicts \(\alpha\) being a bracelet. Therefore \(\mathop{\mathrm{par}}(\alpha)\) is aperiodic. ◻
Lemma 5. The number of periodic nodes in \(\mathbb{T}_n\) is less than or equal to the number of aperiodic nodes in \(\mathbb{T}_n\).
Proof. It suffices to show the existence of a 1-1 mapping \(f\) from the periodic strings in \(\mathbf{A}(n)\) to the aperiodic strings in \(\mathbf{A}(n)\). Let \(\alpha\) be periodic and in \(\mathbf{A}(n)\). Then \(\alpha = \beta^i\) for some aperiodic asymmetric bracelet \(\beta\) where \(i>1\). Let \(p=|\beta|\). Define \(f(\alpha) = 0^{p-1}1 \beta^{i-1}\). Clearly \(f\) is 1-1; if \(f(\alpha)=f(\alpha')\) for some periodic \(\alpha'\in \mathbf{A}(n)\), then \(f(\alpha)\) and \(f(\alpha')\) share the prefix \(0^{p-1}1\), which implies \(\alpha=\alpha'\). Now we prove that \(f(\alpha)\) is aperiodic and is in \(\mathbf{A}(n)\). We must have \(\beta > 0^{p-1}1\), for otherwise \(\alpha\) would be a symmetric bracelet. Thus, \(f(\alpha)\) is an aperiodic necklace, but is not necessarily in \(\mathbf{A}(n)\). Write \(\beta = 0^k1\gamma\) where \(k\geq 1\) and \(\gamma\) is a non-empty string. Since \(\beta\) is an aperiodic bracelet, it is an aperiodic necklace. Therefore, any nonempty proper prefix of \(\beta\) cannot also be a suffix of \(\beta\) [18], and \(\beta\) has no substring \(0^{k+1}\). So \(\beta^R\) must begin with a string larger than \(10^k1\), and thus \(1\beta = 10^k1\gamma < \beta^R1\). It follows that \(f(\alpha)\in \mathbf{A}(n)\). ◻
From equation 1 , we immediately have the following corollary.
Corollary 2. \(n |\mathbf{A}(n)| \leq 2L_n\).
In this section, we present an optimized way to determine the children of a node \(\beta = \mathtt{b}_1\mathtt{b}_2\cdots \mathtt{b}_n\) in \(\mathbb{T}_n\). We use this optimization in
Section 6 to generate orientable sequences in \(O(1)\)-amortized time per bit.
Let \(s\) and \(t\) be integers such that \(\beta\) has prefix \(0^s1\) and suffix \(10^{t}1\). Let \(s'\) denote the largest integer such that \(0^{s'}\) is a substring of \(\mathtt{b}_{s+1}\cdots
\mathtt{b}_n\). Let \(\beta_k\) denote \(\mathtt{b}_1\cdots \mathtt{b}_{k-1}\overline{\mathtt{b}}_k\mathtt{b}_{k+1}\cdots \mathtt{b}_n\); it differs from \(\beta\) only at index \(k\). Recall that \(\tilde{\beta_k}\) is the necklace in \([\beta_k]\). Let denote the maximum of the
integers \(x\) and \(y\). Our goal is to determine the indices \(k\) such that \(\tilde{\beta_k}\) is in \(\mathbf{A}(n)\) and \(\mathop{\mathrm{par}}(\tilde{\beta_k}) = \beta\). Consider the three cases of the parent rule \(\mathop{\mathrm{par}}\):
Suppose \(\mathop{\mathrm{par}}(\tilde{\beta_k}) = \mathop{\mathrm{first1}}(\tilde{\beta_k}) = \beta\). Since \(\beta\) and \(\beta_k\) differ only at index \(k\), it must be that \(k\) is the index of the first \(1\) in \(\beta_k\). Thus \(\tilde{\beta_k} = \beta_k\) has prefix \(0^{k-1}1\) and \(k \leq s\). Since \(\beta_k\) is a necklace, \(k >\) . Suppose \(+ 1 < k < s\) and \(\beta_k\) is not in \(\mathbf{A}(n)\). Note that \(\beta_k\) is a necklace since it has a unique substring \(0^{k-1}\) as a prefix. Thus, it must be that \(1\mathtt{b}_{k+1}\cdots \mathtt{b}_n \geq (1\mathtt{b}_{k+1}\cdots \mathtt{b}_n)^R\). Since \(k+1 \leq s\), this implies that \(1\mathtt{b}_{k+2}\cdots \mathtt{b}_n \geq (1\mathtt{b}_{k+2}\cdots \mathtt{b}_n)^R\) and hence \(\beta_{k+1}\) is also not in \(\mathbf{A}(n)\). Thus, starting from index \(k=\) \(+ 1\) (which may or may not lead to a child), and incrementing up to \(s\), we can stop testing once an index \(k >\) \(+ 1\) does not lead to a child.
Suppose \(\mathop{\mathrm{par}}(\tilde{\beta_k}) = \mathop{\mathrm{last1}}(\tilde{\beta_k}) = \beta\). It follows from Remark [rem:lastone] that \(\tilde{\beta_k} = \mathtt{b}_{k+1}\cdots \mathtt{b}_n0^{k-1}1\). Since \(\tilde{\beta_k}\) is a necklace, it must be that \(k \leq \lceil{s/2}\rceil\). If \(k\) is the smallest index in \(1, 2, \ldots , \lceil s/2 \rceil -1\) such that \(\mathtt{b}_{k+1}\cdots \mathtt{b}_n0^{k-1}1\) is not in \(\mathbf{A}(n)\), then by applying the definition of an asymmetric bracelet, it is straightforward to verify that \(\mathtt{b}_{k+2}\cdots \mathtt{b}_n0^{k}1\) is also not in \(\mathbf{A}(n)\). Thus, starting from index \(k=1\) and incrementing, we can stop testing indices \(k\) for this case once \(\mathtt{b}_{k+1}\cdots \mathtt{b}_n0^{k-1}1\) is not in \(\mathbf{A}(n)\).
Suppose \(\mathop{\mathrm{par}}(\tilde{\beta_k}) = \mathop{\mathrm{last0}}(\tilde{\beta_k}) = \beta\). Then it must be that \(k=n-1\) or \(k=n-2\) from Lemma 3.
Based on this analysis, the function defined in Algorithm 3 will return \(\mathtt{c}_1\mathtt{c}_2\cdots \mathtt{c}_n\) such that \(\mathtt{c}_k = 1\) if and only if \(\tilde{\beta_k}\) is a child of \(\beta\).
Lemma 6. The time required by calls to summed over all \(\beta \in \mathbf{A}(n)\) is \(O(L_n)\).
Proof. Each operation in requires at most \(O(n)\) work, including membership testing to \(\mathbf{A}(n)\), and the parent function. Consider each of the two for loops. In the first for loop on line 6, there are at most two membership tests to \(\mathbf{A}(n)\) that do not detect children; for all other tests the \(O(n)\) work can be assigned to the corresponding child node in \(\mathbf{A}(n)\). For the second for loop starting at line 10, only one membership test to \(\mathbf{A}(n)\) will fail; however, there may be multiple parent tests on line 12 that do not lead to a child. In these cases, \(\mathop{\mathrm{last1}}(\mathtt{b}_{j+1}\cdots \mathtt{b}_n0^{k-1}1) = \beta\), but \(\mathop{\mathrm{par}}(\mathtt{b}_{j+1}\cdots \mathtt{b}_n0^{k-1}1) = \mathop{\mathrm{first1}}(\mathtt{b}_{j+1}\cdots \mathtt{b}_n0^{k-1}1)\). The \(O(n)\) work from each of these parent tests can be assigned uniquely to the node corresponding to the asymmetric bracelet being tested \(\mathtt{b}_{j+1}\cdots \mathtt{b}_n0^{k-1}1\); each node in \(\mathbf{A}(n)\) can receive at most one such assignment because \(\mathop{\mathrm{last1}}(\mathtt{b}_{j+1}\cdots \mathtt{b}_n0^{k-1}1) = \beta\). Since a linear amount of work can be assigned to each \(\beta \in \mathbf{A}(n)\), the time required by calls to summed over all \(\beta \in \mathbf{A}(n)\) is \(O(n |\mathbf{A}(n)|)\). Thus, by Corollary 2 we have our result. ◻
In this section, we present an algorithm based on the recent theory of concatenation trees [5]. It generates the orientable sequences constructed in the previous section in \(O(1)\)-amortized time per bit using \(O(n^2)\) space.
A bifurcated ordered tree is a rooted tree where each node contains two ordered lists of children, the left-children and right-children, respectively. The concatenation tree \(\mathcal{T}_n\) is a bifurcated ordered tree derived from \(\mathbb{T}_n\) that keeps the same parent-child structure, while the label of each node may change from \(\alpha\) to another string in its necklace class \([\alpha]\), and the children are partitioned into to ordered left-children and right-children. The label of each non-root node becomes the string in its necklace class that differs from the label of its parent in exactly one position that we call the change index. The label and change index are unique since periodic nodes appear only at the leaves (see Lemma 4). The root is labeled \(\mathit{r}_n\) (the same label as the root of \(\mathbb{T}_n\)) and assigned change index \(n\). If a node has change index \(c\), its left-children are the children with change index less than \(c\), and the right-children are the children with change index greater than \(c\). In both cases, the children are ordered from smallest to largest based on their change index. As an example, the concatenation tree \(\mathcal{T}_9\) in Figure 4 is obtained from the cycle-joining tree \(\mathbb{T}_9\) illustrated in Figure 2.

Figure 4: The concatenation tree \(\mathcal{T}_9\) derived from the cycle-joining tree \(\mathbb{T}_9\) shown in Figure 2. The small grey box on the top edge of each node indicates the change index; the left-children descend from blue dots \(\bullet\) and the right-children descend from red dots \(\bullet\). The small numbers above each node indicate the order the nodes are visited in an RCL traversal..
A right-current-left (RCL) traversal of \(\mathcal{T}_n\) starts at the root and recursively visits the right-children from first to last, followed by the current node, followed by recursively visiting the left-children from first to last. Let \(\mathop{\mathrm{RCL}}(\mathcal{T}_n)\) denote the sequence generated by traversing \(\mathcal{T}_n\) in RCL order, outputting the aperiodic prefix \(\mathop{\mathrm{ap}}(\alpha)\) as each node \(\alpha\) is visited. The order the nodes of \(\mathcal{T}_9\) are visited by an RCL traversal is illustrated in Figure 4; the corresponding sequence \(\mathop{\mathrm{RCL}}(\mathcal{T}_9)\) is an \(\mathcal{OS}(9)\) of length \(L_9=126\):
| \(000001011~ 111001011~ 011001011~ 110011011~ 110001011~ 100101011~ 100011011\) |
| \(101011011~ 100001001~ 110001001~ 010001001~ 100001011~ 001001011~ 000101011.\) |
In this example, each node \(\alpha\) is aperiodic and hence \(\mathop{\mathrm{ap}}(\alpha) = \alpha\), but this is not always the case.
The following theorem follows directly from the main result in [5], recalling the successor-rule \(g\) defined in Section 3.1.
Theorem 3. For \(n \geq 6\), the sequence \(\mathop{\mathrm{RCL}}(\mathcal{T}_n)\) is an \(\mathcal{OS}(n)\) of length \(L_n\) that has successor-rule \(g\).
To avoid the exponential space required to store a concatenation tree, we demonstrate how to efficiently determine the children of a given node \(\alpha=\mathtt{a}_1\mathtt{a}_2\cdots \mathtt{a}_n\) in \(\mathcal{T}_n\). In particular, given an index \(k\), we want to determine whether or not \(\alpha_k = \mathtt{a}_1\cdots \mathtt{a}_{k-1}\overline{\mathtt{a}}_k\mathtt{a}_{k+1}\cdots \mathtt{a}_n\) is a child of \(\alpha\). From Lemma 4, if \(\alpha\) is periodic, it has no children. Otherwise, \(\tilde{\alpha} = \mathtt{a}_s\cdots \mathtt{a}_n\mathtt{a}_1\cdots \mathtt{a}_{s-1}\) is a node in \(\mathbb{T}_n\) for some \(1\leq s \leq n\); it is the necklace of \([\alpha]\). Thus, if \(\mathtt{c}_1\mathtt{c}_2\cdots \mathtt{c}_n =\) (see Section 5), \(\mathtt{d}_1\mathtt{d}_2\cdots \mathtt{d}_n = \mathtt{c}_s\cdots \mathtt{c}_n\mathtt{c}_1\cdots \mathtt{c}_{s-1}\) is a sequence such that \(\mathtt{d}_k = 1\) if and only if \(\alpha_k\) is a child of \(\alpha\) in \(\mathcal{T}_n\). The procedure , shown in Algorithm 5, applies this observation to generate \(\mathop{\mathrm{RCL}}(\mathcal{T}_n)\) when initialized with \(\alpha = \mathit{r}_n\) and \(c=n\).
Since \(\mathcal{T}_6\) consists only of the root \(r_6 = 001011\), the output of is simply \(001011\).
Theorem 4. For \(n \geq 6\), generates \(\mathop{\mathrm{RCL}}(\mathcal{T}_n)\) in \(O(1)\)-amortized time per bit using \(O(n^2)\) space.
Proof. Each recursive call requires \(O(n)\) space and from Theorem 1, the tree has height less than \(2(n{-}4)\). Thus, the space required by the algorithm is \(O(n^2)\). By Lemma 6, the work required by all calls to is \(O(L_n)\). Ignoring these calls, there is a \(O(n)\) work done at each recursive call to ; determining the necklace and period of a string can be computed in \(O(n)\) time [14]. Since there are \(|\mathbf{A}(n)|\) nodes in \(\mathcal{T}_n\), the total work is \(O(L_n)\) by applying Corollary 2. Thus, the algorithm , which outputs \(L_n\) bits, runs in \(O(1)\)-amortized time per bit. ◻
The values from the column labeled \(L^*_n\) in Table ¿tbl:table:bounds? were found by extending an \(\mathcal{OS}(n)\) of length \(L_n\) constructed in the previous section. Given an \(\mathcal{OS}(n)\), \(\mathtt{o}_1\cdots \mathtt{o}_m\), the following approaches were applied to find longer \(\mathcal{OS}(n)\)s for \(n\leq 20\):
For each index \(i\), apply a standard backtracking search to see whether \(\mathtt{o}_{i}\cdots \mathtt{o}_m\mathtt{o}_1\cdots \mathtt{o}_{i-1}\) can be extended to a longer \(\mathcal{OS}(n)\). We followed several heuristics: (a) find a maximal length extension for a given \(i\), and then attempt to extend starting from index \(i+1\); (b) find a maximal length extension over all \(i\), then repeat; (c) find the “first” possible extension for a given \(i\), and then repeat for the next index \(i+1\). In each case, we repeat until no extension can be found for any starting index. This approach was fairly successful for even \(n\), but found shorter extensions for \(n\) odd. Steps (a) and (b) were only applied to \(n\) up to \(14\) before the depth of search became infeasible.
Refine the search in the previous step so the resulting \(\mathcal{OS}(n)\) of length \(m'\) has an odd number of \(1\)s and at most one substring \(0^{n-4}\). Then we can apply the recursive construction by Mitchell and Wild [3] to generate an \(\mathcal{OS}(n+1)\) with length \(2m'\) or \(2m'+1\). Then, starting from the sequences generated by recursion, we again apply the exhaustive search to find minor extensions (the depth of recursion is significantly reduced). This approach found significantly longer extensions to obtain \(\mathcal{OS}(n+1)\)s when \(n+1\) is odd.
Let \(\mathcal{AOS}(n)\) denote an acyclic orientable sequence of order \(n\). If \(\mathtt{o}_1\mathtt{o}_2\cdots \mathtt{o}_m\) is an \(\mathcal{OS}(n)\), then it follows from our definitions that \(\mathtt{o}_1\cdots \mathtt{o}_m\mathtt{o}_1\cdots \mathtt{o}_{n-1}\) is an \(\mathcal{AOS}(n)\). As noted in [1], none of the \(2^{\lfloor (n+1)/2 \rfloor}\) binary palindromes of length \(n\) can appear as a substring in any \(\mathcal{AOS}(n)\). Thus, a straightforward upper bound on the length of any \(\mathcal{AOS}(n)\) is \[\hat{U}_n = \frac{1}{2}(2^{n} - 2^{\lfloor (n+1)/2 \rfloor}) + (n-1)~~~~\cite{BM}.\]
By applying our cycle-joining based construction, we can efficiently construct an \(\mathcal{AOS}(n)\) of length \(L_n + (n{-}1)\). Previously, the only construction of \(\mathcal{AOS}(n)\)s recursively applied Lempel’s lift [3], requiring exponential space. Starting with an \(\mathcal{OS}(n)\) found by extending a constructed sequence of length \(L_n\) (see Section 7), we apply a computer search to extend the \(\mathcal{OS}(n)\) to an \(\mathcal{AOS}(n)\) by considering each \(\mathtt{o}_{i}\cdots \mathtt{o}_m\mathtt{o}_1\cdots \mathtt{o}_{i-1}\) and attempting to extend in each direction. This approach produced the longest known \(\mathcal{AOS}(n)\)s for \(n=12,13,14\), improving on the lengths discovered by Burns and Mitchell [1] from applying a computer search. The original data from [1] was for \(n \leq 16\); we extend the list of longest known \(\mathcal{AOS}(n)\)s up to \(n=20\).4 These results are summarized in Table 1.
| Constructions | Computer Search | ||||
| \(n\) | Recursion [MW21] | \(L_n + (n{-}1)\) | Extended from \(\OS(n)\) | [BM93] | \(\hat{U}_n\) |
| 6 | 11 | 33 | |||
| 7 | 20 | 62 | |||
| 8 | 92 | 55 | 108 | 108 | 127 |
| 9 | 178 | 134 | 193 | 210 | 248 |
| 10 | 350 | 309 | 435 | 440 | 505 |
| 11 | 692 | 692 | 868 | 872 | 1002 |
| 12 | 1376 | 1541 | 1874 | 1860 | 2027 |
| 13 | 2742 | 3288 | 3732 | 3710 | 4044 |
| 14 | 5474 | 6929 | 7724 | 7400 | 8141 |
| 15 | 10936 | 14534 | 15432 | 15467 | 16270 |
| 16 | 21860 | 29823 | 31560 | 31766 | 32655 |
| 17 | 43706 | 61216 | 63219 | – | 65296 |
| 18 | 87398 | 124461 | 128680 | – | 130833 |
| 19 | 174780 | 252842 | 257340 | – | 261650 |
| 20 | 349544 | 509239 | 519212 | – | 523795 |
In this paper we presented two algorithms to construct orientable sequences with asymptotically optimal length. The first algorithm is a successor rule that outputs each bit in \(O(n)\) time using \(O(n)\) space; the second algorithm generates the same sequences in \(O(1)\)-amortized time per bit using \(O(n^2)\) space by applying a recent concatenation-tree framework [5]. This answers a long-standing open question by Dai, Martin, Robshaw, and Wild [2]. We conclude with the following directions for future research:
Can the lower bound of \(L_n\) for \(\mathcal{OS}(n)\)s be improved?
Can small strings be inserted systematically into our constructed \(\mathcal{OS}(n)\)s to obtain longer orientable sequences?
A problem closely related to efficiently generating long \(\mathcal{OS}(n)\)s is the problem of decoding or unranking orientable sequences. That is, given an arbitrary length-\(n\) substring of an \(\mathcal{OS}(n)\), efficiently determine where in the sequence this substring is located. There has been little to no progress in this area. Even in the well-studied area of de Bruijn sequences, only a few efficient decoding algorithms have been discovered.
Joe Sawada (grant RGPIN-2025-03961) and Daniel Gabrić (grant RGPIN-2026-04863) gratefully acknowledge research support from the Natural Sciences and Engineering Research Council of Canada (NSERC).
This paper was presented in part at Combinatorial Pattern Matching 2024 (CPM 2024) [6].↩︎
Periodic strings are are also known as powers in the literature. The term periodic is sometimes used to denote a string of the form \((\alpha\beta)^i \alpha\) where \(\alpha\) is non-empty, \(\beta\) is possibly empty, \(i\geq 1\), and \(\frac{|(\alpha\beta)^i \alpha|}{|\alpha\beta|}\geq 2\). Under this definition, the word \(\mathtt{alfalfa}\) is periodic, but \(\mathtt{bonobo}\) is not.↩︎
These bounds correspond to \(\tilde{L}_n\) and \(\tilde{U}_n\), respectively, as they appear in [2].↩︎
The resulting \(\mathcal{AOS}(n)\)s generated up to \(n=20\) are available for download at http://debruijnsequence.org/db/orientable.↩︎