I am not sure whether the following pseudo-code can generate an uniformly random permutation
:
PERMUTATE(A):
n = A.length
for i = 1 to n
swap A[i] and A[random(1,n)]
It seems to be right, but can anyone give me a rigorous proof to verify its correctness or wrongness ?