Kth largest element in a max-heap
问题 I'm trying to come up with something to solve the following: Given a max-heap represented as an array, return the kth largest element without modifying the heap. I was asked to do it in linear time, but was told it can be done in log time. I thought of a solution: Use a second max-heap and fill it with k or k+1 values into it (breadth first traversal into the original one) then pop k elements and get the desired one. I suppose this should be O(N+logN) = O(N) Is there a better solution,