Sir can we approach in this way??
let at first we make max heap which takes O(n)
then we search the elements
1st largest takes – 0 comparison
2nd largest take – 1comparison
4th largest takes – 2 comparisons (because 3rd largest worst case at level 3)
.
.
nth largest will take n-1 comparison
total comparison = ∑(n-1)[total logn number fo terms]
=$\frac{logn(logn-1)}{2}$
=O((logn)$^{2}$)
final complexity=O(n)[for building max heap]+O((logn)$^{2}$)[for comparison]
=O(n)