CS 310 Unit 5 Quicksort - CS 310 Unit 5 Quicksort Furman...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 310 Unit 5 Quicksort Furman Haddix Ph.D. Assistant Professor Minnesota State University,  Mankato
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 310 Unit 5 Quicksort  Objectives Introduction to Quicksort A quicksort Algorithm Quicksort Running Time Randomized quicksort Text, Chapter 7
Background image of page 2
Introduction to Quicksort Perhaps, pivotsort or partition sort would have  been better names Divide and Conquer algorithm: Divide: Select a pivot, then divide the non- pivot values into subsets based on the pivot  value,  Conquer: Recusively sort the subsets. Combine: No additional work, as quicksort  sorts in place  Expected running time is O(n lg n) Worst case is O(n 2 ), when array is already  sorted, is in inverted sort order, or nearly one of 
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic Quicksort Algorithm Problem: Sort the array, A[0 … n-1] quicksort(A, 0, n-1); Pseudocode: quicksort(A, p, q) { if(p < q) { int r = partition(A, p, q); quicksort(A, p, r-1); quicksort(A, r+1, q); } }
Background image of page 4
Partitioning the  Subarray 5 11 6 12 7 1 8
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/09/2008 for the course CS 310 taught by Professor Furmanhaddix during the Spring '08 term at Minnesota State University, Mankato.

Page1 / 12

CS 310 Unit 5 Quicksort - CS 310 Unit 5 Quicksort Furman...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online