This preview shows pages 1–2. Sign up to view the full content.
Randomized Algorithms II
By
Sariel HarPeled
, September 28, 2007
±
Version: 0.1
10.1
QuickSort
with High Probability
One can think about
QuickSort
as playing a game in rounds. Every round,
QuickSort
picks a
pivot, splits the problem into two subproblems, and continue playing the game recursively on both
subproblems.
If we track a single element in the input, we see a sequence of rounds that involve this element.
The game ends, when this element ﬁnd itself alone in the round (i.e., the subproblem is to sort a
single element).
Thus, to show that
QuickSort
takes
O
(
n
log
n
) time, it is enough to show, that every element in
the input, participates in at most 32 ln
n
rounds with high enough probability.
Indeed, let
X
i
be the event that the
i
th element participates in more than 32 ln
n
rounds.
Let
C
QS
be the number of comparisons performed by
QuickSort
. A comparison between a
pivot and an element will be always charged to the element. And as such, the number of compar
isons overall performed by
QuickSort
is bounded by
∑
i
r
i
, where
r
i
is the number of rounds the
i
th element participated in (the last round where it was a pivot is ignored). We have that
α
=
Pr
±
C
QS
≥
32
n
ln
n
²
≤
Pr
[
i
X
i
≤
n
X
i
=
1
Pr
[
X
i
]
.
Here, we used the
union rule
, that states that for any two events
A
and
B
, we have that
Pr
[
A
∪
B
]
≤
Pr
[
A
]
+
Pr
[
B
]. Assume, for the time being, that
Pr
[
X
i
]
≤
1
/
n
3
. This implies that
α
≤
n
X
i
=
1
Pr
[
X
i
]
≤
n
X
i
=
1
1
/
n
3
=
1
n
2
.
Namely,
QuickSort
performs at most 32
n
ln
n
comparisons with high probability. It follows,
that
QuickSort
runs in
O
(
n
log
n
) time, with high probability, since the running time of
QuickSort
is proportional to the number of comparisons it performs.
±
This work is licensed under the Creative Commons AttributionNoncommercial 3.0 License. To view a copy of
this license, visit
http://creativecommons.org/licenses/bync/3.0/
or send a letter to Creative Commons,
171 Second Street, Suite 300, San Francisco, California, 94105, USA.
1
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.
This note was uploaded on 06/14/2009 for the course CS 473 taught by Professor Viswanathan during the Fall '08 term at University of Illinois at Urbana–Champaign.
 Fall '08
 Viswanathan
 Algorithms, Sort

Click to edit the document details