uniform distribution from a PRNG

From: aegis (aegis_at_mad.scientist.com)
Date: 01/31/05


Date: 30 Jan 2005 16:12:30 -0800

In my introduction to algorithms book
by Ronald Rivest and some others, they
introduce a way to permute a string by
use of a RAND function that has a uniform
distribution.

Pseudo-code

n <- length[A]
for i <- 1 to n
do swap A[i] <-> A[RANDOM(i, n)]

Now suppose I want to permute the latin alphabet.
That is, generate all possible permutations.

How do they figure that I can generate a different
uniform sequence for each permutation of the latin
alphabet such that I never encounter duplicate
permutations?

Suppose for simplicity, that I permute "abc"

that is 3! permutations

abc
bac
cab
bca
cba
acb

So I should not encounter a sequence such that
causes "abc" to permute to "bac" and then generate
that same sequence again that would permute it in
reverse order. Which would bring me right back
to "abc". A duplicate in this case.

Anyone see how this can be done? Using the pseudo-code
supplied? Any insight would be much appreciated.

Additionally, yes I am aware you can permute things
with recursion, yadda yadda but I am clearly not
after a recursive method. I'm trying to solve the
problem presented.

--
aegis