1
62
Randomized Algorithms
Algorithm can “toss coins”.
No specific input leads to worst-case behavior.
Distinction between
randomized algorithms
and
random data
!
Lecture 5, Oct. 5, 2010
63
Analyzing Quicksort
Partition around a randomly chosen element and let
T(n)
be the
expected time to sort
.
Consider the case where the partition is
(k, n-k-1).
Conditioned
on partition turning to be
(k, n-k-1)
,
the
expected
time to terminate is:
Note that any value of
k
, from
0
to
n-1
is
equally likely
.
T k
T n
k
n
( )
(
)
( )
1
1
0
(
,
1) split)
Pr[(
,
1) split]
(
,
1) split)
1
=
2
( )
( )
( |
( |
( )
(
1
)
( )
( )
k
k
k
n
k
k n
k
k n
k
k n
k
n
n
n
T n
E
T n
T n
T k
T n
k
n
T k

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*