← Heaps & Priority Queues Quiz: all 8 questions
Heaps & Priority Queues Quiz · Question 3 of 8
What does this print? (code)
What does this print?
import heapq
h = [5, 1, 8, 3]
heapq.heapify(h)
print(heapq.heappop(h))
Answer & explanation
Correct answer: 1
Python's heapq is a min-heap, so pop returns the smallest element.
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 →