615.07 - Quick Quick Sort Biostatistics 615/815 Lecture 7...

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

View Full Document Right Arrow Icon
Quick Sort Biostatistics 615/815 ecture 7 Lecture 7
Background image of page 1

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

View Full DocumentRight Arrow Icon
Last Lecture: Shell Sort z Gradually bring order to array by: Sorting sub-arrays including every k th element Using a series of step sizes k , ending with k = 1 ach pass handles nearly sorted arrays where z Each pass handles nearly sorted arrays where insertion sort is efficient z Theoretically, N (log N) 2 complexity is possible
Background image of page 2
Pictorial Representation z Array gradually gains order z Eventually, we approach the ideal case where insertion sort is O(N)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Today: Quick Sort z Most widely used sorting algorithm Possibly excluding those bubble sorts that should be banished! z Extremely efficient O(N log N) z Divide-and-conquer algorithm
Background image of page 4
The Inventor of Quicksort z Sir Charles A. R. Hoare 1980 ACM Turing Award z British computer scientist Studied statistics as a graduate student z Made major contributions to developing computer languages
Background image of page 5

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

View Full DocumentRight Arrow Icon
C. A. R. Hoare Quote “I conclude that there are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies."
Background image of page 6
Caution! z Quicksort is fragile! Small mistakes can be hard to spot Shellsort is more robust (but slower) z The worst case running time is O(N 2 e o st case u g t e s O( ) Can be avoided in nearly all practical settings
Background image of page 7

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

View Full DocumentRight Arrow Icon
Divide-And-Conquer z Divide a problem into smaller sub- problems z Find a partitioning element such that: All elements to the right are greater All elements to the left are smaller Sort right and left sub-arrays independently
Background image of page 8
C Code: QuickSort void quicksort ( Item a [], int start , int stop ) { int i; if ( stop <= start ) return; i = partition ( a , start , stop ); quicksort ( a, start, i - 1 ); quicksort ( a, i + 1, stop ); }
Background image of page 9

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

View Full DocumentRight Arrow Icon
Quicksort Notes z Each round places one element into position The partitioning element z Recursive calls handle each half of array z What would be: good partitioning element? a good partitioning element?
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/26/2011 for the course BIO 615 taught by Professor Abecasis during the Fall '10 term at University of Michigan.

Page1 / 37

615.07 - Quick Quick Sort Biostatistics 615/815 Lecture 7...

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

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