Computer science Algorithms as mathematical objects Theorem
Comparison sort lower bound
Builds on Sorting algorithmDecision tree modelBinary treeStirling's formulaPermutation
Statement
Let , and let be a deterministic comparison sort. Then there is an input of distinct elements on which performs at least comparisons. Moreover, if the input is a uniformly random ordering of distinct elements, the expected number of comparisons of is at least . Since , both bounds are .
Remarks
The proof models on inputs of size as a decision tree: a binary tree whose internal nodes are comparisons and whose leaves are outputs. The orderings of distinct elements need different outputs, so the tree has at least leaves. A binary tree of height has at most leaves, so , and the height is the worst-case number of comparisons. For the average, a binary tree with leaves has average leaf depth at least . The estimate of follows from Stirling's formula.
Example: for , , so no comparison sort sorts every list of distinct items with comparisons; comparisons give only possible outcomes, fewer than the orderings. Merge sort uses comparisons, so the bound is optimal up to a constant factor.
The hypothesis that only comparisons are used is necessary. Counting sort sorts integers in in steps, which is when , by using the values themselves as array indices.
Going deeper
For a student
This is the standard example of a lower bound in a restricted model of computation, the decision tree model. It shows that merge sort and heapsort are asymptotically optimal among comparison sorts. The average case of randomized quicksort, about comparisons, is within a constant factor of optimal. The same counting argument shows that finding an element in a sorted list by comparisons needs about steps, matching binary search.
Reading path
To understand this page from the ground up, read these 84 pages in order. The foundations come first.
- Big O notation definition
- Binary tree concept
- Decision tree model concept
- Limit point of a set definition
- Local maximum definition
- Partition of an interval definition
- Permutation concept
- Sequence definition
- Sorting algorithm concept
- Little o notation definition
- Limit of a function definition
- Local minimum definition
- Mesh of a partition definition
- Riemann sum definition
- Real sequence definition
- Subsequence definition
- Asymptotic equivalence definition
- Continuity at a point definition
- Derivative definition
- Riemann integrable function definition
- Bounded sequence definition
- Cauchy sequence definition
- Geometric sequence definition
- Limit of a sequence definition
- Monotone sequence definition
- Series definition
- Continuous function definition
- Differentiable function definition
- Fermat's theorem on stationary points statement
- Limit superior definition
- Cauchy sequences are bounded statement
- Sum of a finite geometric series statement
- Monotone convergence theorem for sequences statement
- Convergent sequence definition
- Every sequence has a monotone subsequence statement
- Pointwise convergence definition
- Squeeze theorem statement
- Partial sum definition
- Power series definition
- Intermediate value theorem statement
- Differentiable functions are continuous statement
- Derivative function definition
- Bolzano–Weierstrass theorem statement
- The sequence r^n tends to zero for |r| < 1 example
- Radius of convergence definition
- Convergent series definition
- Uniform convergence definition
- Sine and cosine definition
- Boundedness theorem statement
- Product rule statement
- Higher derivative definition
- Cauchy criterion for sequences statement
- Uniform convergence on a set definition
- Absolute convergence definition
- A series of nonnegative terms converges iff its partial sums are bounded statement
- Series of functions definition
- Sum of a series definition
- Extreme value theorem statement
- Continuously differentiable function definition
- Uniformly Cauchy sequence of functions definition
- Geometric series example
- Comparison test statement
- Rolle's theorem statement
- Root test statement
- Ratio test statement
- Weierstrass M-test statement
- Mean value theorem statement
- Cauchy–Hadamard theorem statement
- Ratio formula for the radius of convergence statement
- Power series converge uniformly on smaller discs inside the radius of convergence statement
- Second fundamental theorem of calculus statement
- Uniform convergence of derivatives allows term-by-term differentiation statement
- The exponential series has infinite radius of convergence statement
- Integration by parts statement
- Term-by-term differentiation statement
- Exponential function definition
- Reduction formula concept
- e object
- Power series are differentiable inside the radius of convergence statement
- Derivative of cosine statement
- Wallis product statement
- pi object
- Stirling's formula statement
- Comparison sort lower bound statement
Further reading
About this page
| Tag | GJTE7GGJ7B |
|---|---|
| URI | m2://GJTE7GGJ7B |
| Kind | statement, theorem |
| Writing | W0 stub |
| MSC | 68P10, 68Q25, 68W40 |
| Status | This copy of the site has no build data. Run m2 status GJTE7GGJ7B. |
| About | Sorting algorithm |
| Uses | Sorting algorithm, Decision tree model, Binary tree, Stirling's formula, Permutation |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- an inventory row: the row of the inventory that the node accounts for (0 of 1)
- a source with a locator (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.
What links here
No page links to this page yet.