Merging Sorted Lists: Given n sorted arrays of size k each, we suppose k=4 in our code.
- Create an output array of size n*k.
- Create a min heap of size k and insert 1st element in all the arrays into the heap
- Repeat following steps n*k times. a) Get minimum element from heap (minimum is always at root) and store it in output array. b) Replace heap root with next element from the array from which the element is extracted. If the array doesn’t have any more elements, then replace root with infinite. After replacing the root, heapify the tree