Question 20
Back to Exercise
new PriorityQueue<>(collection) builds the heap with bottom-up heapify. What is its time complexity?
- A O(n) Correct
- B O(n log n)
- C O(log n)
- D O(n²)
Correct Answer: Option A
Most nodes are near the bottom and sift down only a level or two; the total work sums to O(n), better than n separate offers.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!