What does one pop do?
transcript
Three problems use one heap. It holds the front of each list. But the answers all differ. One sentence tells them apart.
For event streams, record the stream. The answer is the stream numbers in order. For documents, pop every equal one. The pops are the lists that hold it. For a range, grow a window. Shrink it when enough lists are covered.
Equal times are common in logs. Put the list number after the time. The heap then breaks every tie the same way. The merged order is now the same on every run.
One thing never changes. After each pop, push the next item. It comes from the same list. If the list is empty, push nothing.
Merge a thousand lists of a hundred items. One list at a time moves fifty million items. The heap pops a hundred thousand times.
Finish the sentence first. Then push the successor. Full breakdown in the lecture.