- #1
courtrigrad
- 1,236
- 2
Hello all:
My program for MergeSort is not working. It keeps saying that Mege is undefined. Here is my code:
How should I fix this problem? Any ideas are greatly appreciated.
Thanks
My program for MergeSort is not working. It keeps saying that Mege is undefined. Here is my code:
Code:
public class MergeSort extends Merge {
public static void mergeSort(int[] a, int first, int last) {
if(last==first) return;
if (last - first == 1) {
// not a[0]>a[1]; this part could test on the upper half of the array
if (a[first] > a[last]) {
int temp = a[first];
a[first] = a[last];
a[last] = temp;
}
} else {
int halfwayPoint = (int) (last + first) / 2;
mergeSort(a, first, halfwayPoint);
mergeSort(a, halfwayPoint + 1, last);
merge(a, first, last, halfwayPoint);
}
}
}
How should I fix this problem? Any ideas are greatly appreciated.
Thanks