Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. Brian W. Kernighan

Shuffle a given array

Language Java | Level Intermediate | Category Algorithms | August 5, 2015 9:18 am


Algorithm Problem Description

Fisher–Yates shuffle is an algorithm for generating a random set. The Fisher–Yates shuffle is quite efficient. Shuffling an array randomizes its element order.

Write a program to randomly shuffle the Array.

Output

          	        
          	        

Original array of items: [1, 2, 3, 4, 5, 6, 16, 15, 14, 13, 12, 11]
After Fisher–Yates shuffle array of items: [6, 11, 15, 2, 5, 4, 3, 13, 16, 12, 1, 14]

          	        
          	        				    


Comments



Please login to add comments.