LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

"Bucket sort" is the name of two different algorithms. How does the version with one bucket per key differ from the version that splits a range into intervals?

With one bucket per possible key value, each bucket holds only equal keys and never needs sorting: $O(n + N)$ and no comparisons (this version is also called pigeonhole sort). The other version splits a range of values, such as real numbers in $[0, 1)$, into about $n$ intervals and sorts each bucket with another algorithm; it is fast only on average, for evenly spread input.

One bucket per key Buckets as intervals
Keys integers in $[0, N-1]$ any numbers in a known range
Bucket $i$ holds exactly the key $i$ all keys in the $i$-th interval
Sorting inside a bucket never needed needed, often with insertion-sort
Comparisons none yes, inside the buckets
Time $O(n + N)$ for every input $O(n)$ on average for evenly spread keys, $O(n^2)$ if all land in one bucket

Counting sort is a close relative of the first version: instead of keeping lists it only counts how many keys of each value occur and computes from the counts where each entry goes. Searching the web for "bucket sort" mostly finds the interval version, so it helps to know that both exist.

Go deeper:

  • doc Bucket sort — the interval version, with its average- and worst-case analysis.
  • doc Counting sort — the counting relative, often used as the per-digit pass inside radix-sort.

From Quiz: ADS / Sorting Lower Bound, Bucket-Sort and Radix-Sort | Updated: Dec 01, 2026