Generating Permutations by a Sequence of Transpositions
The permutations of the set are generated here by starting with this set and successively applying transpositions. At each step the largest element moves back and forth across the other elements, pausing for one step at each end. In the pauses the other elements also move back and forth and also pause. This sequence of permutations can be generated by the Johnson–Trotter algorithm. The list of transpositions used here is constructed by recursion.