notes94

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

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

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.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

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

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

View Full Document
Ask a homework question - tutors are online