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

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 ← 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

1 Expert Approved Answer
Step: 1 Unlock

PERMUTEBYCYCLIC chooses offset as a random integer in the range 1 offset n and t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

C-S-A (24).docx

120 KBs Word File

Students Have Also Explored These Related Algorithms Questions!