Algorithm Alley
by Timothy Rolfe

Example 1:
for ( Src = 0; Src < N; Src++ )
{
   Dest = rand() % N;  // All N positions equally likely
   Swap (X[Src], X[Dest]);
}

Example 2:
for (Dest = N-1; Dest > 0; Dest--)
{
   Src = rand() % (Dest+1);  // Positions from [0] to [Dest]
   Swap (X[Src], X[Dest]);
}


1


