I have n sorted arrays of size n each and I have to merge them.
I am trying to implement this using priority queue as a min heap. Why am I getting wrong output.
Any suggestions . Here is my code:)
Please help me.
Thanks in advance.
You did x.j=1, and later are again incrementing the pointer, basically skipping over an element at start. Here is the other part-
Thats the first error.
Second error, again in same part-
You check if r<n , fine, but then why increment r and then use it? What happens if r=n-1 ? It goes out of bound.
After fixing these two, hopefully your code should work
I made certain changes.
Can you please check if it’s correct now.
Thanks for your time Sire:)
Yes I did.
They were building heap from scratch.
I tried to use priority queue but I am getting wrong answer.
Can you please look into my code for the mistake Sir:)