kberg Feb 16th, 2012 153 Never
  1. The algorithm iterates n times. Each iteration, m, selects a random index from 0-m-1, pulls it from the source array, and pushes it to the destination array. The array is now size m-1. When the array size is 1, the random number generator selects a value from 0-0.
  3. So, when m=1, it selects one possible value
  4. m=2, selects one of two possible values.
  5. m=3, selects one of three possible values.
  6. m=n, selects one of n values.
  8. Now I wave my hands a little to demonstrate my lack of past math skills, and presto! the use of the randomizer results in one of n! possible outcomes.  How's that?
RAW Paste Data