Question: Consider a modification of the Fisher-Yates random shuffling algorithm where we replace the call to random(k + 1) with random(n), and take the for-loop down
Consider a modification of the Fisher-Yates random shuffling algorithm where we replace the call to random(k + 1) with random(n), and take the for-loop down to 0, so that the algorithm now swaps each element with another element in the array, with each cell in the array having an equal likelihood of being the swap location. Show that this algorithm does not generate every permutation with equal probability.
Step by Step Solution
3.36 Rating (162 Votes )
There are 3 Steps involved in it
Suppose n 3 We start with 123 After 1 step we get 123 1... View full answer
Get step-by-step solutions from verified subject matter experts
