% % % \subsection{Elementary linear-delay refinements of two reverse-search trees} \label{sec:elementary-linear} We refine child selection in two existing reverse-search trees: the functional-digraph tree of Defrain, Porreca and Timofeeva~\cite{DPT2024} and the first-inversion tree of Sawada and Williams~\cite{SW2023}. The parent rules and the underlying objects are not new. Reverse search means that every nonroot object has a deterministic parent, and that we enumerate objects by traversing the resulting rooted tree. The expensive step here is finding the next valid child: a short edit can require a comparison of long canonical codes. We show that all but a constant number of these comparisons can be settled by a run-length threshold. This gives explicit worst-case bounds, including first output and exhaustion, and implementations without catalogues or saved ancestor paths. The broad existence bounds must be placed carefully in the literature. Sawada--Williams already give a fixed-content successor with quadratic worst-case time~\cite{SW2021}; their later first-inversion tree is the one used below~\cite{SW2023}. Combining their shift-based successor with Kociumaka's constant-fragment string queries~\cite{Koc2016} gives an alternative linear-time, linear-word successor. The same string queries also yield a linear-word refinement of the original DPT child scan; Section~\ref{sec:koc-dpt-comparison} supplies the reduction rather than attributing it to either source. The useful features of the elementary proofs are their explicit thresholds, their implementation, and the interfaces they make explicit. No priority claim for the broad linear-delay existence bound follows from this section. The distinction can be stated at the level of individual claims. The linear-word existence bounds have short derived comparisons from published tools. The single-boundary child lemmas below instead describe a particular order and avoid those tools' linear-size index. They expose the local structure needed for further space refinements; this appendix establishes the word-space bounds stated below. These exact interfaces, rather than a new reverse-search principle, are the possible separate contribution; their bibliographic priority is not asserted. All bounds count operations on words of $O(\log n)$ bits. A complete functional-digraph code occupies $O(n)$ words. A necklace of length $K$ uses integer symbol ranks $0,\ldots,c-1$, where $c\le K$. Input storage and output copies retained by the caller are distinguished from the iterator's working space. Here \emph{full delay} bounds initialization to the first output, every interval between outputs, and the final exhaustion test. A \emph{stateless cursor} receives the current canonical object but no saved traversal history; it still uses the stated temporary workspace. \subsubsection{The DPT tree: a single uncertain run boundary} The code of an unordered rooted tree is its number of vertices followed by the codes of its immediate subtrees in nondecreasing lexicographic order. Write $\tau=(1)$ for the trivial tree. A connected functional digraph is encoded by the lexicographically least rotation of the sequence of trees attached to its directed cycle. Thus a component code $C=(T_1,\ldots,T_k)$ of total size $n$ contains exactly $n$ integer entries inside its tree codes and at most $n$ tree references. For example, the three-vertex star has code $(3,1,1)$, whereas the three-vertex path has code $(3,2,1)$. Their first unequal entries give the star the smaller code. A cycle decorated by such trees is an ordered sequence only up to rotation, which is why a merge must pass both a local tree-order test and a global rotation test. For rooted trees $A,B$, let $A\mathbin{\star}B$ attach $B$ as the last immediate subtree of the root of $A$. It is a valid sorted tree code exactly when $A$ is trivial or the last immediate subtree of $A$ has code at most $B$. The two inverse candidates at adjacent cycle positions are \[ L_i(C)=(T_1,\ldots,T_{i-1},T_i\star T_{i+1},T_{i+2},\ldots,T_k), \qquad R_i(C)=(T_1,\ldots,T_{i-1},T_{i+1}\star T_i,T_{i+2},\ldots,T_k). \] The DPT parent detaches the last immediate subtree of the first nontrivial tree and replaces that tree by the two resulting parts in nondecreasing order. Its output is already canonical~\cite{DPT2024}. Each parent step increases the cycle length by one; the unique root is the pure $n$-cycle and the depth of $C$ is $n-k$. Fix a noncyclic canonical parent $C$ with $k\ge2$ trees. Let $rq$. Only $D_q$, if it exists, requires a canonicity test. In particular the accepted $D_i$ form a final interval. \end{lemma} \begin{proof} The merge replaces two adjacent trivial trees by the two-vertex tree. The initial trivial run has length $a=i-1$; the remainder of the former initial run has length $b=r-i-1$. The largest other trivial run has length $M$. A canonical word must begin with a longest minimum-symbol run, so a necessary condition is \[ i-1\ge r-i-1,\qquad i-1\ge M. \] These inequalities are exactly $i\ge\lceil r/2\rceil$ and $i\ge M+1$. Thus $iq$, then $a>b$ and $a>M$; the initial run is uniquely longest, and every noninitial rotation is larger. The boundary $i=q$ may tie one or more other runs and is decided by an ordinary linear canonicity test. The conclusion includes the cases in which the interval is empty.\end{proof} When $r=0$ or $r=1$, there are no $D_i$ candidates. When the parent is the pure $k$-cycle, all its two-trivial merges describe the same child, whose code is $(\tau,\ldots,\tau,(2,1))$ with $k-2$ trivial trees. A one-tree component has no children. These cases require no exception to the complexity bound. As a small example, take $C=(\tau,\tau,\tau,\tau,(3,1,1))$. Then $r=4$, $M=0$ and $q=2$. The merge $D_1$ fails, $D_3$ is guaranteed to pass, and only $D_2$ needs inspection. It is $(\tau,(2,1),\tau,(3,1,1))$ and passes because the competing singleton-starting rotation next encounters $(3,1,1)>(2,1)$. The threshold therefore replaces a sequence of full rotation tests. Fix the child order used in the elementary implementation to be \[ D_1,D_2,\ldots,D_{r-1},L_r,R_r,L_{r+1},R_{r+1}, \] after omitting rejected and duplicate candidates. We call this the \emph{position order}. It is generally different from the original DPT convention of trying all $L_i$ before all $R_i$. Both orders enumerate the same classes, but give different successor functions; the four-target argument below uses the position order. \begin{proposition}[Linear DPT queries] \label{prop:elem-dpt-queries} Parent, first child, next child, last child and previous child can each be computed in $O(n)$ worst-case time and $O(n)$ working space, using only the current parent and, for a sibling query, the current child. The child and sibling operations use the position order just specified; a supplied sibling bound must be an actual child of the supplied parent. \end{proposition} \begin{proof} Compute $r$ and $M$ by indexing the existing tree sequence, without copying a suffix for every rejected index. Lemma~\ref{lem:elem-dpt-boundary} skips all indices below $q$ in one step. A forward query needs at most the boundary test and the next guaranteed $D_i$; a reverse query likewise needs at most one boundary test. The exceptional list has at most four members. An existing child's first nontrivial tree, followed by one unmerge, recovers its position and orientation, so either scan can resume without a stored child list. All candidate input trees are already valid. To validate $A\star B$, scan only the immediate-subtree boundaries of $A$ and compare its last subtree to $B$. No recursive validation is necessary. The scan, the comparison, an unmerge, and construction of one candidate each cost $O(n)$. For a linear canonicity test, flatten the component as $0T_1\,0T_2\cdots0T_k$. Its length is $n+k\le2n$. Its least rotation begins at a zero, hence at a tree boundary. Tree codes are prefix-free: different sizes differ in their first entry, and equal sizes give equal code lengths. Thus comparisons between zero-separated rotations agree with comparisons between tree sequences. A standard linear least-rotation algorithm decides canonicity in $O(n)$ time and space. The minimum-rotation primitive itself is standard~\cite{Duval1983}. Only constantly many candidates, code slices, concatenations, and flat words are formed in one query, each of size $O(n)$. Temporary nesting has constant depth. The bounds include unsuccessful queries and all boundary cases. In particular, the argument is a bound on actual scans and copies, not a count that treats variable-length tuple operations as constant time. \end{proof} \subsubsection{Alternating output without an ancestor stack} The following elementary traversal fact will be used twice. An ordered rooted tree is listed by depth-first search, outputting even-depth vertices on entry and odd-depth vertices on exit. Let $P(v)$ denote the parent, $F(v)$ the first child, and $S(v)$ the next sibling; missing vertices are denoted by $\bot$. \begin{lemma}[Stateless alternating successor and predecessor] \label{lem:elem-alternating} If depth parity, parent, first/last child and next/previous sibling can be computed from the current vertex in time $T$ and space $W$, the alternating listing has stateless successor and predecessor in $O(T)$ time and $O(W)$ space. Consecutive outputs are at tree distance at most three. A three-edge transition consists of a crossing between consecutive siblings and one additional edge incident with one of those siblings. \end{lemma} \begin{proof} After output at an even vertex $v$, first try $u=F(v)$. If it exists, the next output is $F(u)$ when that child exists and otherwise $u$. If $F(v)=\bot$, the next output is $S(v)$ when it exists and otherwise $P(v)$. After output at an odd vertex $v$, if $u=S(v)$ exists, the next output is $F(u)$ when it exists and otherwise $u$. If $S(v)=\bot$, put $p=P(v)$; the next output is $S(p)$ when it exists and otherwise $P(p)$. A missing result means exhaustion. These cases follow directly from entry output at even depths and exit output at odd depths. They make only a constant number of the stated queries. For a predecessor, interchange even and odd, first and last, and next and previous in the same cases. The root has no predecessor. Reading the short paths in these formulas proves the distance bound and the stated form of the three-edge case. Only the current vertex and a constant number of temporary query results are retained.\end{proof} \begin{theorem}[Connected and arbitrary functional digraphs] \label{thm:elem-dpt-linear} The unrestricted connected $n$-vertex functional digraphs can be listed up to isomorphism with $O(n)$ worst-case delay and $O(n)$ working space. The successor and predecessor of a canonical connected code are stateless with the same bounds. All, possibly disconnected, $n$-vertex functional digraphs also admit $O(n)$ delay and $O(n)$ working space. \end{theorem} \begin{proof} For connected codes, parity is $(n-k)\bmod2$ and can be recovered in $O(n)$ time. Apply Proposition~\ref{prop:elem-dpt-queries} and Lemma~\ref{lem:elem-alternating}. Constructing the initial $n$-cycle and detecting exhaustion both fit $O(n)$. For arbitrary graphs enumerate nondecreasing integer partitions of $n$. In a partition prefix with remaining sum $R$ and lower bound $a$, the possible next parts are $a,\ldots,\lfloor R/2\rfloor$, followed by $R$. Every such branch has a completion. A depth-first leaf iterator stores an $O(n)$-deep stack of constant-size integer records; between leaves it traverses $O(n)$ edges, each with constant-time next-child control. Thus partitions have $O(n)$ delay and space, including copying a partition. For a fixed partition with $p_i$ parts of size $i$, enumerate $p_i$-element multisets of connected size-$i$ codes in the fixed connected listing order. To advance a multiset, try positions from right to left; after advancing one position, fill the later positions with that new code. No numerical ranks are required. Immutable code references may be shared. The cost is $O(p_i i)$. Product carries and resets therefore cost \[ \sum_i O(p_i i)=O(n), \] and the component states occupy $O(n)$ words. Every size has a connected component, so every partition contributes an output. The transition to a new partition also costs $O(n)$ and creates no empty-product gap. \end{proof} The explicit-output bound is optimal if every output's $n$ integer entries must be written. It does not assert that an implicit local-change description requires $\Omega(n)$ time. \subsubsection{Fixed content: an elementary one-boundary LCP lemma} A necklace here is the lexicographically least word in a rotation class; its \emph{content} specifies how many times each ordered symbol occurs. We keep that content fixed. The goal is not to sort or rank all necklaces, but to navigate a particular reverse-search listing. For two words, $\operatorname{LCP}$ denotes the number of equal initial symbols before their first mismatch, capped at their common length. Let $w=w_0\cdots w_{K-1}$ be a necklace. Its first descent index is \[ d=\min\{iw_{i+1}\}, \] with $d=K-1$ when $w$ is nondecreasing. Let $r$ be its initial run length of the minimum symbol $w_0$, and let $v_i$ exchange $w_i,w_{i+1}$. Sawada and Williams prove that exchanging the first descent of a necklace leaves a necklace~\cite[Lemma~9 in the author manuscript]{SW2023}. Accordingly, the first-inversion parent needs no canonical rotation. Each parent step removes exactly one inversion, so its root is the nondecreasing word of the fixed content and its depth is the inversion number. \begin{lemma}[All inverse positions] \label{lem:elem-necklace-positions} The children of $w$ are precisely the canonical $v_i$ satisfying either \begin{align*} &id+1$, the earlier descent at $d$ survives unchanged. At $i=d+1$, that descent is repaired exactly when $w_d\le w_{d+2}$, giving (B). These are all possibilities. The first descent of an accepted child uniquely recovers its index, proving distinctness.\end{proof} Case (A) has at most one ascent with minimum left symbol: $i=r-1$. We test this candidate separately. All its remaining candidates satisfy $r\le iw_0$. Write \[ L_j=\operatorname{LCP}(w,\operatorname{rot}_j(w)),\qquad L=\max_{dL$. Only the single position $i=L$ requires a canonicity test. \end{lemma} \begin{proof} The swap at $i\ge r$ leaves the leading run of $r$ minimum symbols unchanged. A rotation starting at $1\le jd$ can compete. Fix such a start. As $ii\quad\hbox{and}\quad q+1a$. If $L_ji$, including an equal rotation with $L_j=K$, the rotation still has $a$ at the first changed position $i$, whereas $v_i$ has $b$. It is therefore strictly smaller than $v_i$. Only $L_j=i$ leaves a comparison to resolve. Taking the maximum over all relevant starts proves the lemma. Starts with nonminimum first symbol have $L_j=0$ and do not affect the conclusion.\end{proof} The uncertain equality case is real. For example, $w=01203$ has $L=1$ and its swap at $i=1$ is canonical; $w=01202$ has the same boundary but its swap there is not canonical. Periodic words are included: a nontrivial equal rotation gives $L=K$, rejecting every high-symbol predescent ascent. \begin{proposition}[Linear necklace child queries] \label{prop:elem-necklace-queries} First/next and last/previous child in the first-inversion tree can be found in $O(K)$ worst-case time and $O(K)$ space. Each query makes at most three ordinary linear canonicity tests. \end{proposition} \begin{proof} Compute the Z-array of $ww$, of length $2K$. Then $L_j=\min(K,Z[j])$ for $1\le jL$ is guaranteed to be a child. Finally test the single case-(B) candidate. Reverse this order for a backward query. The first descent of an existing child recovers its index in a linear scan. The full tests occur only at the minimum-run boundary, the LCP boundary, and the case-(B) position. There are constantly many copied candidate words. The Z-array, doubled word, and least-rotation buffers occupy $O(K)$ words, and an empty or exhausted query has the same bound. \end{proof} \begin{lemma}[Linear inversion parity] \label{lem:elem-inversion-parity} For a length-$K$ word on dense ranks $0,\ldots,c-1$, $c\le K$, inversion parity can be computed in $O(K)$ time and space. \end{lemma} \begin{proof} Count each symbol and form its prefix count. Send the occurrence at position $i$ to its position $p_i$ in a stable sorted word: \[ p_i=\#\{j:w_j1. \] A nontrivial adjacent transposition changes inversion parity. A cyclic boundary transposition has the same property after rotation, because parity is rotation-invariant here. Thus the necklace adjacency graph is bipartite with parts of sizes $E,O$. A Hamilton path can alternate between parts only when their sizes differ by at most one, a contradiction. For $(4,4)$ specifically, there are six even and four odd necklaces. \end{proof} This obstruction concerns \emph{adjacent} transpositions. It does not exclude Gray codes by arbitrary transpositions, shifts, two adjacent transpositions, or bounded changes of a functional digraph's outgoing targets. Small Hamilton-path certificates in the square of the necklace adjacency graph are useful evidence for a two-swap question, but they do not establish a theorem for all contents. Similarly, the three-swap listing of Theorem~\ref{thm:necklace-linear} and the four-target realization of Proposition~\ref{prop:elem-four-targets} do not by themselves give an implicit loopless generator: the search computations proved here remain linear in the code length.