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

  1. A.O(1)
  2. B.O(n)
  3. C.O(log n)
  4. 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 →