TAOCP 1.3.3 Exercise 2

The transformation is given by (a,b,c,d,e,f)\leftarrow(c,d,f,b,e,a), which induces the mapping $a\mapsto c$, $b\mapsto d$, $c\mapsto f$, $d\mapsto b$, $e\mapsto e$, $f\mapsto a$.

Section 1.3.3: Applications to Permutations

Exercise 2. [10] The text shows how we might set $(a, b, c, d, e, f) \leftarrow (c, d, f, b, e, a)$ by using a series of replacement operations $(x \leftarrow y)$ and one auxiliary variable $t$. Show how to do the job by using a series of exchange operations $(x \leftrightarrow y)$ and no auxiliary variables.

Verified: yes
Solve time: 1m22s


The transformation is given by

$$ (a,b,c,d,e,f)\leftarrow(c,d,f,b,e,a), $$

which induces the mapping $a\mapsto c$, $b\mapsto d$, $c\mapsto f$, $d\mapsto b$, $e\mapsto e$, $f\mapsto a$. The cycle decomposition is $(a,c,f)(b,d)$ with $e$ fixed.

Each exchange $(x\leftrightarrow y)$ swaps the current positions of $x$ and $y$.

Starting from $(a,b,c,d,e,f)$:

$(a\leftrightarrow c)$

$(c,b,a,d,e,f)$

$(b\leftrightarrow d)$

$(c,d,a,b,e,f)$

$(a\leftrightarrow f)$

$(c,d,f,b,e,a)$

After these three exchanges, the required arrangement is obtained, and no auxiliary variable is used. This completes the construction. ∎