I have got an array containing unique elements. I need to find out the first n largest elements in the array in the least complexity possible. The solution that I could thin
Use a modified version of Quick Sort. You do not need to actually sort the whole array. You only need to partition N elements larger than the pivot value. For more information, please read Introduction to Algorithms.