Can you prove that the below code produces a random permutation, where RANDOM(i, n) produces a random integer in (i, n]
RANDOMIZE-IN-PLACE(A)
n = length[A]
for i =0 ... n-1
do swap (A[i], A[RANDOM(i, n)])
What Games Are: Xbox One Is Microsoft's Spruce Goose
-
[image: H-4_Hercules_2]Microsoft's Xbox One presents a big and complicated
machine whose primary purpose is a menu layer for watching television. This
in a...
33 minutes ago
Generating random permutation is equivalent to repeated selection of a random number from 1 to n without replacement. This is what the code is doing precisely.
ReplyDelete