Generating Signed Permutations by Twisting Two-Sided Ribbons

Yuan,Aaron Williams
2024-06-14
Abstract:We provide a simple and natural solution to the problem of generating all $2^n \cdot n!$ signed permutations of $[n] = \{1,2,\ldots,n\}$. Our solution provides a pleasing generalization of the most famous ordering of permutations: plain changes (Steinhaus-Johnson-Trotter algorithm). In plain changes, the $n!$ permutations of $[n]$ are ordered so that successive permutations differ by swapping a pair of adjacent symbols, and the order is often visualized as a weaving pattern involving $n$ ropes. Here we model a signed permutation using $n$ ribbons with two distinct sides, and each successive configuration is created by twisting (i.e., swapping and turning over) two neighboring ribbons or a single ribbon. By greedily prioritizing $2$-twists of the largest symbol before $1$-twists of the largest symbol, we create a signed version of plain change's memorable zig-zag pattern. We provide a loopless algorithm (i.e., worst-case $\mathcal{O}(1)$-time per object) by extending the well-known mixed-radix Gray code algorithm.
Data Structures and Algorithms
What problem does this paper attempt to address?
The paper mainly discusses the problem of generating signed permutations. The author proposes a simple and natural method to generate all 2n·n! signed permutations of [n] by twisting two-sided ribbons. Here, [n] represents {1,2,...,n}. This method is an extension of the well-known Steinhaus-Johnson-Trotter algorithm (plain changes), which generates permutations by swapping adjacent symbols. In plain changes, permutations are formed by intertwining parallel ropes. The author handles signed permutations by extending the rope model to ribbons with two different sides. Each consecutive configuration is created by twisting two adjacent ribbons or a single ribbon, which corresponds to symbol swapping. By prioritizing 2-twists of the largest symbol, followed by 1-twists of the largest symbol, the author constructs an order called "twisted plain changes," which is a cyclic Gray code for generating signed permutations. The paper also introduces basic combinatorial generation knowledge, including the greedy Gray code algorithm, and provides a detailed description of the algorithm for generating twisted plain changes. This algorithm is a loop-free implementation, meaning the generation time for each object is constant in the worst case. Additionally, the author provides a Python implementation of the algorithm as an appendix. In summary, this paper solves the problem of generating signed permutations with an efficient method, provides a model that is both simple and intuitive, and presents an efficient loop-free algorithm.