LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

Can any sorting algorithm, comparison-based or not, beat linear time, and how much does a linear-time sort gain over $n\log n$?

No algorithm can sort in less than linear time: it has to look at each of the $n$ elements at least once, because an element it never reads could belong anywhere. Reaching that floor saves the factor $\log n$ over $n\log n$: about 10 for a thousand elements, about 20 for a million.

Bucket-sort and radix-sort reach the floor when the key range and the number of digits are fixed, and nothing can do better than that. So the step from $n\log n$ down to $n$ is the last one there is, and it is much smaller than the step before it:

$n$ $n^2$ $n\log_2 n$ $n$
1 000 1 000 000 about 10 000 1 000
1 000 000 $10^{12}$ about 20 000 000 1 000 000

Going from $n^2$ to $n\log n$ gains a factor of 100 at a thousand elements and 50 000 at a million; going from $n\log n$ to $n$ gains 10 and 20. Worth having, but only while the key range $N$ stays small: bucket-sort's $O(n + N)$ carries a second term that can eat the whole gain.

Go deeper:

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