Heap-type permutation generation with a prescribed final arrangement
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.
Create a lesson
Metadata
- Categories
- math.CO, cs.DM, cs.DS
- Comments
- 22 pages. Software archived at https://doi.org/10.5281/zenodo.24311260
Related papers
Counting Matrices of Prescribed Jordan Type in Incidence Algebras
Shared title terminologymath.COKeivan Mallahi-Karai, Samrith Ram, Hadi Salmasian
Pieri formula for the torus-equivariant quantum K-theory of flag manifolds of type A
Shared title terminologymath.COSatoshi Naito, Khanh Nguyen Duc, Daisuke Sagaki
The mean orders of even and odd permutations
Shared title terminologymath.COManoj Kumar Singh
Three almost symmetric metatiles generate the Spectre tiling
Shared title terminologymath.COSimon Tatham
Spectral radii of connected graphs with prescribed maximum degree
Shared title terminologymath.COFengming Dong
A general triangle generation of the d-dimensional Genocchi numbers
Shared title terminologymath.CODerek Hanely, Edison Muçllari, Vasily Zadorozhnyy