Author: Rob KennedyRob Kennedy Date: Aug 5, 2008 17:51
> The code can be found here: http://pastebin.com/f7f49e556
>
> I translated from a Java source, at the moment I can't find it, but if
> I do I'll post it.
Mergesort is a pretty basic algorithm. It shouldn't need translating
from other languages.
If you ever find the Java code, take another look at it. Does it have
something like this:
int i = 0;
int j = lo;
while (j <= med) {
B[i++] := A[j++];
}
I suspect it does. You've translated it wrong. Those are
*post*-increment operators. They evaluate to the *current* value of i
and j, not the incremented values. The first index assigned in B is 0,
not 1.
Now look at your code.
|