Question: Write a method, shuffle(A), that rearranges the elements of array A so that every possible ordering is equally likely. You may rely on the nextInt(n)
Write a method, shuffle(A), that rearranges the elements of array A so that every possible ordering is equally likely. You may rely on the nextInt(n) method of the java.util.Random class, which returns a random number between 0 and n−1 inclusive.
Step by Step Solution
3.42 Rating (161 Votes )
There are 3 Steps involved in it
This problem can easily be solved in On time by using the FisherYates Shuffle algorithm ... View full answer
Get step-by-step solutions from verified subject matter experts
