Give an Okn algorithm that merges k sorted lists with a tota
Give an O(kn) algorithm that merges k sorted lists with a total of n elements into one sorted list.
Solution
The straightforward solution is to create the result array of size n*k and then copy all arrays one by one to it. Finally, sort the result array using any O(nLogn) sorting algorithm which takes O(nkLognk) time.
Explanation :-
We can merge k sorted lists with a total of n elements into one sorted list.in O(kn) time using Min Heap Algorithm.
