Implement an algorithm to shuffle an array of numbers or objects. The algorithm for shuffling should be

Question:

Implement an algorithm to shuffle an array of numbers or objects. The algorithm for shuffling should be the following:

for (each index i) { choose a random indexj where j >= i. swap the elements at indexes i and j.

(The constraint about j being greater than or equal to i is actually quite important, if you want your shuffling algorithm to shuffle fairly. Why?)

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: