Resource · Guide or article
Fisher–Yates shuffle
Plain-language description of the Fisher-Yates shuffle for producing an unbiased random ordering in place.
Reviewed
Open the original: Fisher–Yates shuffle (opens the original site in a new tab)Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
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.
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Reference
What it covers
- Drawing-from-a-hat intuition for picking the next element.
- Claims of unbiased output, linear time in the number of items, and in-place operation.
How to use it
PrepKit study advice, not a claim made by the source.
Write the in-place shuffle, shuffle [1, 2, 3] many times, and check that all six orders appear about equally often.
Scope and limitations
Only one paragraph: no step list, pseudocode, or common mistakes. The single reference is Wikipedia.
Access and format
Free English README on GitHub; trekhleb/javascript-algorithms, MIT license.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/algorithms/sets/fisher-yates/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.