please tell why my code is giving the wrong output
Please tell why my code is giving the wrong output
there are some mistakes in your code:-
(i) The maximum value of n is 2*10^5 so the default size of your both the arrays a and temp should be greater than that as you have used int a[10005] which is less.
(ii) Inside your merge function the index of the temp are taken wrong by you, either taken them as 0 to till the required or take them same as the original array.
actually, Your for loop in the end of the merge function is wrong. it should align with the values.
Feel free to ask any furthur doubts in this question if you have.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.