Title: Spectral Analysis of Internet Topologies
1Lecture 4, Wed. Aug 27 03.
Today
Quicksort Design Paradigm Recursion, Divide
Conquer, Randomization !!! Performance O(n
log n) comparisons, In Place ! Reading CLRS,
Chapter 7, and these
lecture notes.
2Quicksort is a Recursive Divide Conquer
Algorithm
sort elements smaller than s
sort elements larger than s
3By picking random splitters we create, on the
average, O( log n) recursion depth,
for a total number of comparisons, on the
average, O(n log n) .
Why do we expect recursion depth log n
? Because, even if we are unlucky and pick bad
splitters for a few rounds, we expect that, it
is unlikely to continue picking bad splitters for
too long, and pretty soon we are bound to pick a
good splitter.
Say that a splitter is good if it creates two
partitions whose sizes are within constant
Factors of each other, eg 1/2 ,1/2 or 1/4,3/4,
otherwise say that the splitter is bad. If all
splitters are good then the recursion depth is
definetely O( log n).
4(No Transcript)
5(No Transcript)
6Complexity Analysis
T(n) Expected Number of Comparisons
Notice the partition is balanced, on the average
!!!
Formula is too messy to start substitutions. Will
bring it to slightly easier form.
7Solve by Substitution