QuickSelect ============= Background ------------ The problem we are trying to solve here is that of finding the k'th largest (or smallest) of a collection of data (hereafter referred to as the array). The array is therefore considered to be unordered because, of course, if it were ordered, it would be a matter of mere indexing to get the k'th largest value. The Plan ---------- The idea behind quickSelect is to run a partial quicksort on the data. Partial in that instead of recursing down both halves of the pivot-partitioned data, we only recurse down the half where the k'th largest would be. This requires a slight modificaton of the partition algorithm to return the position where the equal partition starts so we know what half to recurse into. Analysis ---------- Recursing only down half the array at a time makes this turn out linear instead of n*log(n) overall and so is a goodly speedup from sorting the data before finding the k'th largest. Smallest Finding ------------------ Finding the k'th smallest can be done by just finding the n-k'th largest. Easy peasy, right?