The original shuffleArray function was not uniform. This can be proved by noting that there are n-1 choices at each of the n positions of the array, but (n-1)^n is not divisible by n! (n factorial). The new proposed function should produce every permutation with equal probability.
The original shuffleArray function was not uniform. This can be proved by noting that there are n-1 choices at each of the n positions of the array, but (n-1)^n is not divisible by n! (n factorial). The new proposed function should produce every permutation with equal probability.