← 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)
- A.Peek at min/max: O(1)
- B.Push: O(log n)
- C.Pop: O(log n)
- 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 →