I am getting output as 0 0 0 …
I am not able to find the error.
Merge k sorted arrays(heap problem)
@nayakashutosh99 hey ashutosh why are you working on address you are taking input as 2d array and using a linear array of which storing address if you dereference your array you will find this is giving garabage value so don’t code like this
follow this algo
Create an result[] of size n*k.
Create Min-Heap of type HeapNode.( HeapNode- Every Node will store the data and the list no from which it belongs).
Now take one element from each of the K list and create HeapNode object and insert into min-Heap.
Extract the minimum Node from the min-Heap, insert the data into result array.
The extracted node will also contain the list to which it belongs, insert the next element from that list into min-Heap.
If any point of time any list gets over, insert +∞ into min-Heap.
Keep repeating until all the K list gets over.