Question: Suppose that instead of swapping element A[i] with a random element from the subarray A[i ..n], we swapped it with a random element from anywhere

Suppose that instead of swapping element A[i] with a random element from the subarray A[i ..n], we swapped it with a random element from anywhere in the array:
PERMUTE-WITH-ALL (A)
1 n ← length [A]
2 for i ← 1 to n
3 do swap A[i] ↔ A [RANDOM (1, n)]
Does this code produce a uniform random permutation? Why or why not?

Step by Step Solution

3.45 Rating (171 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The PERMUTEWITHALL procedure does not produce a uniform random permutation Conside... 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 (23).docx

120 KBs Word File

Students Have Also Explored These Related Algorithms Questions!