This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Algorithm QuickSelect (array A , k ) If k &gt; length(A) then return no answer; if single element in array then return it as the answer; // k must be = = 1 in the above case pick a pivot from the array and QuickPartition the array; // as is done in QuickSort ) say, the left half of A is L including the pivot, and say, the right half is R ; if length (L) k then QuickSelect (L, k) else QuickSelect (R, k  size(L) 1); // previous calls kth element is kL1 in R End algorithm. Q3. Prove the correctness of the MergeSort Algorithm presuming the input size is a power of 2....
View
Full
Document
 Spring '12
 Dmitra
 Algorithms, Sort

Click to edit the document details