Skip to content

Files

Latest commit

e36c441 · Jul 4, 2018

History

History
This branch is 11 commits behind trekhleb/javascript-algorithms:master.

fisher-yates

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Apr 26, 2018
Apr 26, 2018
Jul 4, 2018

Fisher–Yates shuffle

The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence—in plain terms, the algorithm shuffles the sequence. The algorithm effectively puts all the elements into a hat; it continually determines the next element by randomly drawing an element from the hat until no elements remain. The algorithm produces an unbiased permutation: every permutation is equally likely. The modern version of the algorithm is efficient: it takes time proportional to the number of items being shuffled and shuffles them in place.

References

Wikipedia