🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Heaps & Priority Queues Quiz: all 8 questions

Heaps & Priority Queues Quiz · Question 1 of 8

What are the costs of a binary heap's operations? (select all that apply)

What are the costs of a binary heap's operations? (select all that apply)

  1. A.Peek at min/max: O(1)
  2. B.Push: O(log n)
  3. C.Pop: O(log n)
  4. D.Search for any value: O(1)
Answer & explanation

Correct answer: Peek at min/max: O(1) · Push: O(log n) · Pop: O(log n)

A heap only keeps the top element in a known place; finding an arbitrary value means scanning, O(n).

Can you get the rest right without peeking?

Take the timed Heaps & Priority Queues Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →