October 2025
Intermediate to advanced
485 pages
13h 2m
English
Let’s visually walk through the Fisher-Yates Shuffle algorithm for the array [1, 2, 3, 4, 5].
Step 1: We point to the first index in the array:

Step 2: We randomly choose one of the indexes from our pointer and rightward. For now, this can be any index of our array.
We’ll indicate the random index with a die. Say that our randomly chosen number is a 3:

The number the die lands on represents the index that we’re going to swap with. In this case, the index is 3 (and that slot happens to contain the value 4). In ...
Read now
Unlock full access