The University of Texas at Austin
Department of Computer Sciences
Professor Vijaya Ramachandran
Lecture 21
CS357: ALGORITHMS, Spring 2006
Lower bound on comparisonbased sorting
There are several algorithms that sort
n
elements in
O
(
n
log
n
) time using
only comparisons between pairs of input elements in order to obtain their
relative ordering. These include MergeSort and Heapsort and also Quicksort
(expected time when randomized).
An algorithm that sorts
n
elements by only making comparisons between
pairs of input elements in order to deduce their relative order will be called
a
comparisonbased algorithm
. We will now show that any comparisonbased
algorithm for sorting must make Ω(
n
log
n
) comparisons and hence must have
Ω(
n
log
n
) running time.
Let
A
be such an algorithm. As described in the textbook, we will capture
the comparisons it makes on every input of length
n
in terms of a binary
decision tree
.
Thus the decision tree represents all comparisons made by the algorithm on
every input of length
n
, but ignores data movement and other aspects of the
algorithm. The leaves of this decision tree represent all possible outputs for
an input of length
n
: for diFerent inputs we take diFerent paths down the
tree and reach diFerent leaves. Notice that there are
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '06
 Ramachandran
 Algorithms, Sort, Professor Vijaya Ramachandran

Click to edit the document details