Professor Armstrong suggests the following procedure for generating a uniform random permutation:
PERMUTE-BY-CYCLIC (A)
1. n← length[A]
2. offset ← RANDOM(1, n)
3. for i←l to n
4. do dest←i + offset
5. If dest > n
6. thendest← dest —n
7. B[dest] A[i]
8. return B
Show that each element A[i] has a 1/n probability of winding up in any particular position in B. Then show that Professor Armstrong is mistaken by showing that the resulting permutation is not uniformly random.
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.