Resource · Guide or article
Bucket Sort
Bucket sort, which scatters values into buckets, sorts each, and gathers them, plus how its running time depends on the input distribution.
Reviewed
Open the original: Bucket Sort (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
Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. Then, elements are sorted within each bin: The computational complexity depends on the algorithm used to sort each bucket, the number of buckets to use, and whether the input is uniformly distributed.
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
- Four-step algorithm: set up buckets, scatter, sort each bucket, gather.
- Worst case O(n^2) when insertion sort is used per bucket and all items land in one bucket.
- Average O(n + k) for k buckets when input is reasonably uniform.
How to use it
PrepKit study advice, not a claim made by the source.
Implement it for floats in [0, 1), then feed it clustered data and explain the slowdown.
Scope and limitations
Brief; the illustrations are image files and the only reference is Wikipedia. No exercises.
Access and format
English README, free on GitHub, part of the MIT-licensed trekhleb/javascript-algorithms project.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/algorithms/sorting/bucket-sort/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.