Professor Kelp decides to write a procedure that will produce at random any permutation besides the identity permutation. He proposes the following procedure:
PERMUTE-WITHOUT-IDENTITY (A)
1. n → length[A]
2. for i← 1 to n
3. do swap A[i]↔ A[RANDOM(i + 1,n)]
Does this code do what Professor Kelp intends?
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.