Comparison Decision Trees and Sorting Lower Bounds
Count distinguishable input orders to obtain a sorting lower bound and identify the computational model that makes it apply.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Every order needs an outcome
Consider a deterministic algorithm sorting \(n\) distinct records using only comparisons of their keys. Each branch checks which of two keys is smaller. The terminal leaf fixes the permutation used to output those records. A single leaf cannot serve two distinct input order types, because they require different output permutations. The comparison tree consequently has at least \(n!\) leaves, so its worst-case depth is at least
\[ \lceil\log_2(n!)\rceil=\Omega(n\log n). \]
For the asymptotic lower bound, multiply just the largest \(\lfloor n/2\rfloor\) factors of the factorial.
Changing the query model changes the tree
An algorithm exploiting bounded integer key representations can inspect digits or address buckets directly, as in radix sorting. These operations are outside the two-way comparison model. Likewise, selection can identify a single requested rank with linear comparisons because it leaves most other ranks unresolved. The tree argument counts distinguishable outcomes under specified operations and does not say each sorted input takes the worst-case number of comparisons.[1][2]