🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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…

  1. A.A min-heap of size k
  2. B.A max-heap of all n elements
  3. C.A sorted array of size n
  4. 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 →