Intuition
Merging sorted lists into one is done with a min-heap of size holding the current front element of each list. You repeatedly extract the global minimum and push the next element from the list it came from. Each of the output elements pays one extract-min plus one insert, each .
Result
- a constant : , because is just a constant factor.
- growing with : the factor stays. The extreme (all singleton lists) turns merging into a full comparison sort, forcing the comparison lower bound. So linear time is impossible.
Worked example
Merge lists of size in ? That would sort arbitrary keys with comparisons, contradicting . Hence only constant gives .
build min-heap from heads of all k lists // O(k)
repeat n times:
x = extractMin() // O(log k)
output x
insert next element of x's list // O(log k)
// total: Theta(n log k)
Pitfall: Do not treat as the magic boundary. Every fixed (e.g. , ) merges in since collapses to a constant; the real divide is constant versus that scales with .