[2603.22147]
Nathaniel K. Brown, Ahsan Sanaullah, Shaojie Zhang, Ben Langmead
The move structure represents a permutation $π$ of $[0,n)$ as a covering set of $O(r)$ disjoint intervals (contiguous subsets of $[0,n)$), where $r$ is the minimum number of intervals whose values permute together. Formally, $r = 1 + |\{i\in [1,n) : π(i) - 1 \neq π(i-1)\}|$. The move structure takes $O(r)$ words of space. Given the index of the interval containing $i$, it allows computing $π(i)$ and the index of the interval containing $π(i)$ in $O(1)$-time. Therefore, for permutations where $r \ll n$, it allows their representation and navigation in significantly compressed space. The previous best $O(r)$-space move structure construction algorithm takes $O(r\log r)$-time. In this paper, we describe a construction algorithm achieving optimal $O(r)$-time and space. We also show that using our improved algorithm within a recent previous work allows the computation of the longest common prefix array in $O(r)$-working space and optimal $O(n)$-time given the run-length-encoded Burrows-Wheeler transform. Finally, we implement our improved move structure construction algorithm and find that it is faster than the previous best algorithm while using comparable memory.