← Heaps & Priority Queues Quiz: all 8 questions
Heaps & Priority Queues Quiz · Question 2 of 8
To find the k-th LARGEST element in O(n log k), you keep…
To find the k-th LARGEST element in O(n log k), you keep…
- A.A min-heap of size k
- B.A max-heap of all n elements
- C.A sorted array of size n
- D.A queue of size k
Answer & explanation
Correct answer: A min-heap of size k
The min-heap holds the k largest seen so far; its top (the smallest of them) is the k-th largest.
Can you get the rest right without peeking?
Take the timed Heaps & Priority Queues Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →