← Quiz: Queue, Deque and PriorityQueue: all 10 questions
Quiz: Queue, Deque and PriorityQueue · Question 7 of 10
What is the time to poll() from a PriorityQueue of n elements?
What is the time to poll() from a PriorityQueue of n elements?
- A.O(1)
- B.O(n)
- C.O(log n)
- D.O(n log n)
Answer & explanation
Correct answer: O(log n)
After removing the root, the last element moves down the tree, which has about log n levels.
Can you get the rest right without peeking?
Take the timed Quiz: Queue, Deque and PriorityQueue quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →