Shuffle Card of Desk

Shuffle Card of Desk

Shuffle card of desk, it must be perfect shuffle, mean each of 52! permutations of the deck has to equally likely.
Algorithm:
  1. Iterate 1 to 52
    1. During each iterate get random number between 1 to current position
    2. Swap card of current position with random position

Latest Source Code:
Github: ShuffleCardOfDeck.java


Output:

 Before Shuffle: 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 
15 16 17 18 19 20 21 22 23 24 25 26 27 
28 29 30 31 32 33 34 35 36 37 38 39 40 
41 42 43 44 45 46 47 48 49 50 51 52 

After Shuffle: 
25 34 43 3 35 48 12 44 13 4 30 29 38 8 
47 37 33 45 23 14 2 27 52 15 28 7 6 
11 36 18 9 51 39 31 49 17 46 42 10 41 
24 5 21 1 22 50 32 40 20 19 16 26 
Author: Hrishikesh Mishra