The shuffling algorithm of
Fisher-Yates.
Time complexity: O(N).
Time complexity: O(N).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array
|
Array which should be shuffled. |
Returns:
- Type:
-
Array
Shuffled array.
Example
var shuffle = require('path-to-algorithms/src/' +
'shuffle/fisheryates').shuffle;
console.log(shuffle([1, 2, 3, 4, 5])); // shuffled array