Question: How do i find the kth largest element in a (max) priority queue in O(k) time? I know there is an a scientific article out
How do i find the kth largest element in a (max) priority queue in O(k) time?
I know there is an a scientific article out there which describes some complicated way of finding the kth smallest element in a min-heap in O(k), but this is for an introductory course on algorithms. I also read that doing a breath-first search might be a solution but i cant see how. Can anyone help?
EDIT
i stumbled upon this on the wikipedia entry on min-max heap: "The structure can also be generalized to support other order-statistics operations efficiently, such as find-median, delete-median,[6]find(k) (determine the kth smallest value in the structure) and the operation delete(k) (delete the kth smallest value in the structure), for any fixed value (or set of values) of k. These last two operations can be implemented in constant and logarithmic time, respectively."
can anyone elaborate on this maybe?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
