Shuffle of an array elements.
This algorithm is modified version of Fisher-Yates shuffle
algorithm and is introduced by Richard Durstenfeld.
Time complexity: O(N).
Time complexity: O(N).
Parameters:
| Name | Type | Description |
|---|---|---|
array |
Array | An array which should be shuffled. |
- Source:
Returns:
Shuffled array.
- Type
- Array
Example
var shuffle = require('path-to-algorithms/src/shuffle' +
'/richarddurstenfeld').shuffle;
console.log(shuffle([1, 2, 3, 4, 5])); // random shuffled