Docsity

Lecture Slides on Sorting III: Quick Sort | COMP 4030, Study notes of Algorithms and Programming

Partial preview of the text

Download Lecture Slides on Sorting III: Quick Sort | COMP 4030 and more Study notes Algorithms and Programming in PDF only on Docsity!

COMP 4/6030: Introduction to Algorithms

Sorting III February 15, 2006

Outline {

4 sorting algorithms

z Insertion sort z Quick sort z Merge sort z Heap sort {

Lower bound

{

Aims

z Correctness z Analysis (running time) z Design (divide and conquer) z Different algorithms for a same problem, optimality

Lower bounds for comparison sorting {

How fast can we sort?

{

Lower bounds

z

(n) to examine all the input z All sorts seen so far are

(nlgn) z To prove:

(nlgn) is a lower bound {

Decision tree

z Abstraction of any comparison sort { Abstract away everything else: control and datamovement { Count only comparisons z Represents comparisons made by { A particular sorting algorithm { On input of a given size

Optimality { Which is asymptotically optimal? z Insertion sort z Quick sort z Merge sort z Heap sort