Question: 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
PERMUTE-BY-CYCLIC (A)
1 n ← length [A]
2 offset ← RANDOM (1, n)
3 for i ← 1 to n
4 do dest ← i + offset
5 if dest > n
6 then dest ← 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.
Step by Step Solution
3.45 Rating (152 Votes )
There are 3 Steps involved in it
PERMUTEBYCYCLIC chooses offset as a random integer in the range 1 offset n and t... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
C-S-A (24).docx
120 KBs Word File
