English

Generating Signed Permutations by Twisting Two-Sided Ribbons

Data Structures and Algorithms 2024-06-17 v2

Abstract

We provide a simple and natural solution to the problem of generating all 2nn!2^n \cdot n! signed permutations of [n]={1,2,,n}[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!n! permutations of [n][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 nn ropes. Here we model a signed permutation using nn 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 22-twists of the largest symbol before 11-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 O(1)\mathcal{O}(1)-time per object) by extending the well-known mixed-radix Gray code algorithm.

Cite

@article{arxiv.2311.06974,
  title  = {Generating Signed Permutations by Twisting Two-Sided Ribbons},
  author = {Yuan and Qiu and Aaron Williams},
  journal= {arXiv preprint arXiv:2311.06974},
  year   = {2024}
}

Comments

15 pages, 7 figures

R2 v1 2026-06-28T13:18:44.476Z