











































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An analysis of the quicksort algorithm, including its history, divide and conquer approach, worst-case and best-case running times, and average runtime. It also discusses the concept of randomized quicksort and its advantages.
Typology: Study notes
1 / 51
This page cannot be seen from the preview
Don't miss anything!












































2/5/
CS 5633 Analysis of Algorithms
Carola Wenk
Slides courtesy of Charles Leiserson with small
changes by Carola Wenk
2/5/
CS 5633 Analysis of Algorithms
like merge sort).
2/5/
CS 5633 Analysis of Algorithms
Running time=
n
) for
n
elements. Running time=
n
) for
n
elements.
P
ARTITION
(
A
,
p
,
q
)
⊳
A
[
p
..
q
]
x
←
A
[
p
]
⊳
pivot =
A
[
p
]
i
←
p
for
j
←
p
to
q
do if
A
[
j
]
≤
x
then
i
←
i
exchange
A
[
i
]
↔
A
[
j
]
exchange
A
[
p
]
↔
A
[
i
]
return
i
x x
x
x
x
x
p
i
q
j
Invariant:
CS 5633 Analysis of Algorithms
i
j
CS 5633 Analysis of Algorithms
i
j
CS 5633 Analysis of Algorithms
i
j
CS 5633 Analysis of Algorithms
i
j
CS 5633 Analysis of Algorithms
i
j
CS 5633 Analysis of Algorithms
i
j
CS 5633 Analysis of Algorithms
i
j
CS 5633 Analysis of Algorithms
i
CS 5633 Analysis of Algorithms
UICKSORT
p, r
if
p
r
then
q
ARTITION
p, r
UICKSORT
p, q
UICKSORT
q+
, r
Initial call:
UICKSORT
, n
2/5/
CS 5633 Analysis of Algorithms
2
n
n
n
n
n
n n T T n T
(arithmetic series)
CS 5633 Analysis of Algorithms
n
n
cn