Generating key points…
Answers are grounded in this paper and cite their sources.
Ruskey, Savage and Wang asked whether the necklace tests in their binary rotation-and-flip tree could run in constant amortised time per output. The answer is yes for every length \(n≥ 1\). The implementation visits the same candidates in the same order, including the first rejected candidate at each node where a rejection occurs. It takes \(O(N_2(n))\) total time and \(O(n)\) working words, where \(N_2(n)\) is the number of length-\(n\) binary necklaces. Each output is a constant-cost callback to the current mutable representation. Copying the full word carries an additional cost. Ruskey, Savage and Wang, *Generating Necklaces*, §3, Theorem 5, Fig. 5 and concluding paragraph, author version pp. 13–17 A binary necklace is a rotation class of binary words. Its representative is the lexicographically least rotation, with \(0<1\). Let \(σ\) rotate a word one position to the left and let \(τ\) complement its final bit. Emit \(0^n\) and then start a depth-first search at \(0ⁿ⁻¹1\), emitting each node on entry. At a node \(y\), test \(τσ^j(y)\) for \(j=1,…,n-1\) in increasing order. Recurse immediately on each candidate that is its own least rotation, resume at the next index on return, and stop testing at the first failure. The range follows the prose of §3, which supplies the upper limit omitted from the displayed loop in Fig. 5. At \(n=1\) the range is empty. The original traversal theorem gives one output per rotation class. Store each nonzero representative as a circular list of the lengths of the zero runs preceding successive ones, allowing zero-length runs. Keep a pointer to the leading run and doubly linked buckets indexed by run length from \(0\) through \(n\). If the leading run of \(y\) has length \(A\), a probe with \(1≤ j≤ A\) replaces it with a leading run of length \(a=A-j\) and appends a final run of length \(j-1\), keeping the intervening runs in order. These changes and their undo take constant time. The first possible in-range probe beyond \(A\) is \(j=A+1\). It flips a one and leaves a nonzero candidate ending in zero, so it fails. For the probes within the leading run, let \(b_r\) count the other runs of the parent of length \(r\). With \(L_0=0\), maintain \(L_j=Lⱼ₋₁+bA-j+1\) from the restored parent state. Then \(L_j\) counts the other old runs longer than \(a\). Reject if \(L_j>0\) or \(j-1>a\). If these checks pass and \(a=0\), accept the all-ones word. Otherwise, compare only with rotations starting at other runs of length \(a\). Compare successive run lengths until the first difference or one full circuit. A longer run at the first difference gives the smaller binary word. Accept exactly when none of the rotations is smaller, allowing equality for periodic words. The total cost of these remaining comparisons is controlled by a statistic of uniformly random labelled circular binary words. For a word \(w\), let \(M(w)\) consist of the starts of its longest positive zero runs, each immediately preceded by a one. Take \(M(w)\) to be empty for constant words. For distinct \(i,k∈ M(w)\), let \(i,k\) be the common-prefix length of the two periodic bit tails after the ones that close their respective runs, capped at \(n\) bits. Set \(κ(w,i)=∑_{k∈ M(w)\{i\}}(1+i,k)\) for \(i∈ M(w)\) and set it to zero otherwise. For \(W\) uniform on \(\{0,1\}^n\), \[∑_{w∈\{0,1\}^n}κ(w,0)=2^n/n\, E\![∑ᵢ₌₀ⁿ⁻¹κ(W,i)], E\![∑ᵢ₌₀ⁿ⁻¹κ(W,i)]≤ C \] for an absolute constant \(C\) independent of \(n\). The bound accounts for both the frequency of tied longest runs and the length of the agreement after them, including overlapping tails. Each probe entering these comparisons has a distinct oriented word. Undoing its final flip and taking the least rotation recovers its parent, and its leading run length determines \(j=A-a\). The comparison cost is therefore \(O(2^n/n)\), including comparisons on rejected probes. Since each rotation class contains at most \(n\) labelled words, \(2^n/n≤ N_2(n)\). The time bound is amortised over the full traversal. Constant worst-case delay and Gray order remain separate questions.
No takes yet. Share an insight, caveat, or question.
Zixuan He (2026) studied this question.
Synapse has enriched 8 closely related papers on similar clinical questions. Consider them for comparative context: