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

  1. It's sorting, not shorting.
  2. You don't seem to copy back the temporary array.
  3. 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 < end with end in your case being the last index.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .