🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Heaps and Heap Sort Internals: all 15 questions

Quiz: Heaps and Heap Sort Internals · Question 10 of 15

In Java, what does new PriorityQueue<(Collections.reverseOrder()) give you?

In Java, what does new PriorityQueue<>(Collections.reverseOrder()) give you?

  1. A.A sorted list
  2. B.A min-heap
  3. C.A stack
  4. D.A max-heap, where poll() returns the largest element
Answer & explanation

Correct answer: A max-heap, where poll() returns the largest element

PriorityQueue is a min-heap by default; a reversed comparator makes the largest element come out first.

Can you get the rest right without peeking?

Take the timed Quiz: Heaps and Heap Sort Internals quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →