Heap-type permutation generation with a prescribed final arrangement
Lu\'is M. S. Russo
Key points
From the paper's conclusion- We show that the output of each call is a concatenation of right cosets of the symmetric group on one item fewer, and we prove a general formula: the order in which the items are parked at the last position may be chosen freely, every such order corresponds to exactly one valid schedule, and it determines the net permutation of the call.
Abstract
Heap's algorithm generates all permutations of an array of n items, obtaining each one from its predecessor by a single swap. We determine the net permutation applied to the array by every complete recursive call: a transposition when the number of items is odd and at least three, and a cycle through all items when it is even. We show that the output of each call is a concatenation of right cosets of the symmetric group on one item fewer, and we prove a general formula: the order in which the items are parked at the last position may be chosen freely, every such order corresponds to exactly one valid schedule, and it determines the net permutation of the call. Two variants follow. In the cyclic variant a complete sweep over an even number of items rotates the array by one position. In the extremal variant, for even n, a sweep started from the identity ends in the lexicographically largest arrangement that any single-swap enumeration can leave; by a parity argument this is the reversal exactly when n is congruent to 2 modulo 4. The construction of the extremal variant is proved correct when n is divisible by 4 and verified by computer for all even n up to 10000.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Ranking and Unranking Permutations in Heap's OrderarXiv · 2026
- The counts of parity-odd vs even late-growing permutations in the group $\mathbb{S}_{2p-1}$ differ by $(-1)^p$arXiv · 2026
- Iterating the Lehmer code on inversion sequences: Catalan fixed points and finite stabilizationarXiv · 2026
- On the generation of the symmetric group by index relations of three prefix reversalsarXiv · 2026
- The mean orders of even and odd permutationsarXiv · 2026
- A Geometric Derivation of the Bitner--Ehrlich--Reingold Loopless Gray Code AlgorithmarXiv · 2026