21/37
Part 4 of 6 · Time limitsLearn and do
A count in each heap entry stops a tie from comparing keys
Heap items are tuples, compared one field at a time:
import heapq
heap = []
heapq.heappush(heap, (5, "a"))
heapq.heappush(heap, (5, 7))
heappush (5, "a"), then (5, 7). What happens?
Pick one to see what it prints.
Pick an answer above to see the rest