Knuth Card Shuffling Algorithm Code Snippet
Knuth Card Shuffling Algorithm Code Snippet
Move through the array from top to bottom (i.e, index 0,1,..,n), swapping each card in turn with another card from a random position in the part of the pack that has not yet been passed through (including itself). With unbiased random numbers, it always generates a random permutation. Complexity: O(n)
Read More:
http://linkmingle.com/details/795
Thanks