What is the time complexity of this optimised approach using heaps ?
Merge K sorted array
Complexity Analysis:
- Time Complexity : O( n * k * log k), Insertion and deletion in a Min Heap requires log k time. So the Overall time compelxity is O( n * k * log k)
- Space Complexity : O(k), If Output is not stored then the only space required is the Min-Heap of k elements. So space Comeplexity is O(k).