K-Way Merge
Merging many sorted sources through one funnel.
This animation merges k sorted lists into one — the heart of Merge k Sorted Lists.
Each conveyor belt is a sorted list feeding toward a central funnel. The funnel holds exactly one candidate per belt: the smallest not-yet-taken element of each list. Every step, the smallest of those k candidates lights up, rolls onto the output track, and its belt advances one slot to send in a replacement.
The invariant to watch: the output track fills in perfect sorted order, even though no belt knows anything about the others. It works because the global smallest remaining element is always someone's front element — so comparing just k candidates is enough; the millions of elements further back can be ignored.
In the real algorithm the funnel is a min-heap (a structure that hands you its smallest item in O(log k) time), so each of the N total elements pays one heap pass: O(N log k) overall. Compare that with merging the lists one pair at a time, where early elements get re-merged over and over — O(N times k). Watch the step counter: the funnel touches each ball exactly once.