Write merge method for mergeSort method, it takes the array ofdata, starting index of first half, starting index of second halfand end index of second half.
please use the code below to test it
public class A4Sort{ public static void mergeSort(int[] a, int l, int h){ if (l >= h) return; int mid = (h + l) / 2; mergeSort(a, l, mid); mergeSort(a, mid + 1, h); merge(a, l, mid + 1, h); } public static void main(String[] args){ int[] a = {3,2,7,5,1,6,4,8,9}; System.out.println(“mergeSort a: “); long time, nextTime; time = System.nanoTime(); mergeSort(a, 0, a.length – 1); nextTime = System.nanoTime(); System.out.println(“tTime used: ” + (nextTime – time) + ” nseconds”); for (int i = 0; i < a.length; i++) System.out.print(a[i] + “,”); System.out.println(); }}
Expert Answer
Answer to Write merge method for mergeSort method, it takes the array of data, starting index of first half, starting index of sec…