Give an O (n lg k)-time algorithm to merge k sorted lists into one sorted list code example
Example: Give an O (n lg k)-time algorithm to merge k sorted lists into one sorted list
Analysis: It takes O(k) to build the heap; for every element, it takes O(lg k) to DeleteMin
and O(lg k) to insert the next one from the same list. In total it takes O(k + n lg k) =
O(n lg k).