Generating permutations using swaps of adjacent elements

discrete mathematicspermutations

Is it possible to generate all permutations of order n in a sequence
by successive swaps of adjacent elements only, such that each
permutation appears exactly once?

for example, for n = 3 (* denotes the next swap): $$ 1*2-3 $$$$ 2-1*3 $$$$ 2*3-1
$$
$$ 3-2*1 $$$$ 3*1-2 $$$$ 1-3*2 $$

for n = 4, there is a pattern of length 8 that repeats 3 times:
$$ 1*2-3-4 $$$$ 2-1*3-4 $$$$ 2-3-1*4 $$$$ 2-3*4-1 $$$$ 2-4-3*1 $$$$ 2-4*1-3 $$$$ 2*1-4-3 $$$$ 1-2*4-3 $$

Also, the patterns themselves got me curious. Is there a way to generate them?

Best Answer

Yes! You are asking if the cayley graph of the symmetric group with a basis of transpositions is hamiltonian.

In fact this is true, and was proven in Kompel'makher and Liskovet's "Sequential Generation of Arrangements by Means of a Basis of Transpositions".

This is only a 5-page paper, and a fairly easy read. Moreover, it describes an algorithm for finding these cycles using only the swaps $(1,i)$ for $2 \leq i \leq n$, the so called "star-shaped basis".


I hope this helps ^_^

Related Question