Question: I have the following code but need help in returing. yes. here is my code. also below will be the test code public class MergeSortTest

I have the following code but need help in returing. yes. here is my code. also below will be the test code public class MergeSortTest { private static void randomIntArray(Integer arr[], int min, int max) { int mn = Math.min(min, max); int mx = Math.max(min, max) + 1; for(int i = 0; i < arr.length; i++) { int value = (int)(Math.random() * (mx - mn)) + mn; arr[i] = Integer.valueOf(value); } } package mergeSort; public class MergeSort { public static void sort(Object arr[]) {} private static void mergeSort(Object arr[], Object tempArray[], int first, int last) { if(first < last) { int mid = first + (last - first) / 2; mergeSort(arr, tempArray, first, mid); mergeSort(arr, tempArray, mid + 1, last); merge(arr, tempArray, first, mid, last); }} private static void merge(Object arr[], Object tempArray[], int first, int mid, int last) { int beginHalf1 = first; int endHalf1 = mid; int beginHalf2 = mid + 1; int endHalf2 = last; int index = 0; while(beginHalf1 <= endHalf1 && beginHalf2 <= endHalf2); int res = ((Comparable) arr[beginHalf1]).compareTo(arr[beginHalf2]); if(res <= 0) { } else { } while(beginHalf1 <= endHalf1) { tempArray[index] = arr[beginHalf1]; index ++; beginHalf1++; } while(beginHalf2 <= endHalf2) { tempArray[index] = arr[beginHalf2]; index++; beginHalf2++; for(int i = 0, j = first; i <= (last - first); i++, j++) { arr[j] = tempArray[i]; } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!