From last couple of days I am trying to write code for Merge sort. I have completed Week3 lectures and trying to solve pset3. Need some help in my code for merge sort. The code seems to work fine with array of size 2. However if we go with array of size more then 2. The output of the program is not correct. I am unable to find the bug or error. Can any one help me in this. my code for merge sort
- It's sorting, not shorting.
- You don't seem to copy back the temporary array.
- Your indices are inconsistent. It's usually best to pass the first index of a range and the first index no longer in that range (so the difference is the number of elements in the range). You seem to compensate this with
a < mid+1, but then use
a < endwith
endin your case being the last index.