Number of ways to choose elements to swap I'm trying to work through a question in a textbook. 
For 3 elements, there are 3! = 6 permutations. That I understand. But I don't get the below statement:
"For 3 elements, the number of ways to choose elements to swap is 3 to the power of 3 = 27". How is it 27? Could someone here explain?
Thanks,
 A: Consider a 3 elements
A B C
The first iteration swaps A with another element at random, i.e. either A, B or C, so the three equally likely configurations after the first iteration are:
no change   ->   A  B  C
swap with B  ->  B  A  C
swap with C  ->  C  B  A
The second iteration starts with one of the three arrangements generated at the first iteration and the swaps are:
Second position with first position gives one of:
A B C -> B A C
B A C -> A B C
C B A -> B C A
Second position with second position gives one of:
A B C -> A B C
B A C -> B A C
C B A -> C B A
and finally second position with third position gives one of:
A B C -> A C B
B A C -> B C A
C B A -> C A B
So now we have nine equally likely arrangements after the second shuffle. That is:
B A C
A B C
B C A
A B C
B A C
C B A
A C B
B C A
C A B
The final step is to randomly move the final element to a new random position and this has three possibilities.
The third element is moved to the first element.
The third element is moved to the second.
And finally, the third element is moved to the third position.
Thus, in total resulting to 27 possible outcomes.
Reference : How Not To Shuffle : Mike James
