Run time error code


there is a “run-error” in all the 3 test cases. i am not able to figure out what it is. All the test cases i try they run just fine

Hi!
There is a problem with the logic of your code. For Merge Sort, you have to make 2 funtions

  1. mergeSort(int *a,int s,int e)
    This takes the arraym start and endp pts. This function will Divide the array into 2 parts(say x and y are the new arrays), sort those 2 parts and then merge those 2 arrays again.

  2. void merge(int *x,int *y,int *a,int s,int e)
    Here x and y are the new arrays that were created by mergeSort function.

Please mark the doubt as resolved if you’re satisfied with the explanation.

Thanks!

Also check the comments in the above code for more clarity.

the code still gives a run error


There were still some errors, I have commented them.

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.