Due Wednesday, 10/13
- Does an algorithm with Properties A, B and C necessarily
generate all permutations with equal probability
- From the book, page 86, questions 4 and 5 (I think...I'll
check and correct this if it's wrong. It's the problems that I
mentioned in class.)
|
Some
Algorithms:
Here are some algorithms which attempted, not always successfully, to
generate a random permutation on n
elements:
Algorithm 1: Flip a
coin. On H, do n - 1
random swaps, on T do n - 2
random swaps.
This algorithm worked for n =1,
2 and 3, but failed to generate permutations uniformly for n = 4.
Algorithm 2: Start
with the array A[i] = i for i = 1..n. Select a random r in the interval [1..n] and send each element i to (i + r) (mod n).
This algorithm had property A,
but generates only n different permutations, not n!.
Algorithm 3: Flip a
coin. If it's H, return the identity permutation. If it's
T, return the reverse permutation.
This algorithm had property B, but generates only 2
different permutations, not n!.
Algorithm 4:
|