What is the most efficient algorithm to find the kth smallest/largest element in an array having n elements?
There is a good discussion on the available algorithms with pseudocode, complexity and possible implementations here:
Here's a sorting and then a quickselect plus a minheap implementation:
http://www.programcreek.com/2014/05/leetcode-kth-largest-element-in-an-array-java/
Comments
Post a Comment