Unformatted text preview: To form L, E we sort at both ends Complexity of Quicksortin the expected case at every call of quicksort, the pivot x will divide L and G in two sets that will, on average, be the same sizeThe work done in the algorithm for one element is the number of times the element is movedin every call to qsSubrange we move each element only once in the subrange. Therefore an element is moved at most log(n) timesHowever in the worst case we could choose x (the pivot) such that either L or G are emptyWill only happen when the array is already sortedEven with this problem, quicksort is very popular because it's fast and the common case is O(n log(n))...
View
Full
Document
This note was uploaded on 02/04/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue.
 Fall '08
 Staff
 Sort, Quick Sort

Click to edit the document details