Overview
The Steinhaus-Johnson-Trotter Algorithm enumerates permutations in adjacent-transposition order by tracking mobile elements and changing their directions.
Generates permutations so adjacent outputs differ by one adjacent swap.
Compact metadata for implementation and discovery.
The Steinhaus-Johnson-Trotter Algorithm enumerates permutations in adjacent-transposition order by tracking mobile elements and changing their directions.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n!) generated permutations
Average
O(n!) generated permutations
Worst
O(n!) generated permutations
Space
O(n) direction and permutation state plus output storage if materialized
Show mobile elements, direction arrows, and adjacent swaps between successive permutations.
Steinhaus-Johnson-Trotter generates permutations by adjacent transpositions; procedural-generation is the closest current Atlas category.
What each reference supports for this entry.
Defines Johnson-Trotter as generating permutations by adjacent swaps and records Steinhaus-Johnson-Trotter aliases.
Open sourceSupports the adjacent-transposition permutation-generation method underlying the Johnson-Trotter family.
Open sourceSupports Algorithm 115, PERM, as an early permutation-generation algorithm associated with the Trotter-Johnson naming.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Steinhaus-Johnson-Trotter and Heap's Algorithm are alternative deterministic permutation-generation methods.