I know that we can find the 2nd largest element in an array of size N
in N+log(N)-2
using a "tournament" algorithm. Now I wonder if we can find the k-th largest element using a similar "tournament".
I know there is an O(N)
"selection" algorithm to find the k-th largest element. It uses Quick Select
with a "good" pivot, which can be found in O(N)
. We can build also a heap
from the array in O(N)
and retrieve k element from the heap
.
I wonder if there is another approach.