Question 3
Back to Exercise
After pushing 5, 1 and 9 with heapq.heappush, what does heappop return first?
- A 9 – heapq is a max-heap
- B 5 – it is a queue
- C 1 – heapq is a min-heap Correct
- D A random element
Correct Answer: Option C
Negate values (or use nlargest) to get max-heap behaviour.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!