← 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?
- A.A sorted list
- B.A min-heap
- C.A stack
- 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 →