Select K largest number from N
Anónimo
The answer is something called quickselect. It's similar to quicksort, only that once an array is partitioned, you simply ignore the portion that does not contain the Kth position. You aim for the pivot to fall on the Kth position. Interestingly enough, the complexity for an average case is O(n).