
lower bound for sorting

(Proof)


Several wellknown sorting algorithms have average or worstcase running times of
(heapsort, quicksort). One might ask: is it possible to do better?
The answer to this question is no, at least for comparisonbased sorting algorithms. To prove this, we must prove that no algorithm can perform better (even algorithms that we do not know!). Often this sort of proof is intractable, but for comparisonbased sorting algorithms we can construct a model that corresponds to the entire class of algorithms.
The model that we will use for this proof is a decision tree. The root of the decision tree corresponds to the state of the input of the sorting problem (e.g. an unsorted sequence of values). Each internal node of the decision tree represents such a state, as well as two possible decisions that can be made as a result of examining
that state, leading to two new states. The leaf nodes are the final states of the algorithm, which in this case correspond to states where the input list is determined to be sorted. The worstcase running time of an algorithm modelled by a decision tree is the height or depth of that tree.
A sorting algorithm can be thought of as generating some permutation of its input. Since the input can be in any order, every permutation is a possible output. In order for a sorting algorithm to be correct in the general case, it must be possible for that algorithm to generate every possible output. Therefore, in the decision tree representing such an algorithm, there must be one leaf for every one of permutations of input values.
Since each comparison results in one of two responses, the decision tree is a binary tree. A binary tree with leaves must have a minimum depth of
. But
has a lower bound of
(see asymptotic bounds for factorial). Thus any general sorting algorithm has the same lower bound.
This result does not necessarily apply to noncomparisonbased sorts, such as the radix sort. Comparisonbased sorts  such as heapsort, quicksort, bubble sort, and insertion sort  are more general, in that they depend only upon the assumption that two values can be compared (which is a necessary condition for the sorting problem to be defined for a particular input anyway; see total order). Sorting algorithms such as the radix sort take advantage of special properties that need to hold for the input values in order to
reduce the number of comparisons necessary.
 1
 Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein. Introduction to Algorithms, second edition. MIT Press, 2001.

"lower bound for sorting" is owned by stevecheng. [ full author list (2)  owner history (1) ]


(view preamble)
See Also: binary tree, Landau notation
This object's parent.
Crossreferences: properties, total order, necessary, insertion sort, bubble sort, asymptotic bounds for factorial, lower bound, binary tree, generate, order, permutation, depth, height, leaf nodes, represents, internal node, sequence, sorting problem, state, root, tree, class, entire, even, quicksort, heapsort, running, average
There is 1 reference to this entry.
This is version 3 of lower bound for sorting, born on 20020527, modified 20060509.
Object id is 2948, canonical name is LowerBoundForSorting.
Accessed 6580 times total.
Classification:
AMS MSC:  68P10 (Computer science :: Theory of data :: Searching and sorting)   68P30 (Computer science :: Theory of data :: Coding and information theory ) 



Pending Errata and Addenda







