notes94 - Notes by Akshar Mehta QuickSort(s) if s has only...

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

View Full Document Right Arrow Icon
Notes by Akshar Mehta QuickSort(s) if s has only 1 element return s otherwise choose pivot x and divide S into L, E, G such that Y ε L, Y < x Y ε E, Y == x Y ε G, Y > x call quicksort(L) quicksort(G) reassemble S, L, E, G In worst case, if pivot is chosen such that L or G are empty, we will need to call quicksort more than O(nlogn) . In fact, in this case, quicksort degenerates to O(n 2 ) ; If pivot is chosen in such a way that L and G have the same size, the recursive calls to quicksort all have sets that are half the size of teh original quicksort. In this case, looking at execution tree, i.e. binary tree, each number is copied at most O(logn) i.e. depth of tree. Since we have n elements, then if we choose the pivot such that L, G are equal everytime the quicksort takes O(n logn) i.e. the expected case. RADIX SORT - Considers the structure of keys to be sorted. - Assumes that the keys are represented as a binary number of a fixed number of bits. 1) It examines the bits of each of the keys from right to left.
Background image of page 1

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

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

This note was uploaded on 02/02/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 3

notes94 - Notes by Akshar Mehta QuickSort(s) if s has only...

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

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