Question: Can someone assist me fix the following code? Java program for MergeSort Directions: public static void mergeSort(int[] nums, int left, int right) { if (left

Can someone assist me fix the following code? Java program for MergeSort

Directions:

Can someone assist me fix the following code? Java program for MergeSort

public static void mergeSort(int[] nums, int left, int right) { if (left mid +1) { if (m mid +1) { if (m

System.out.println("nums = " + Arrays.toString(nums)); }

After it runs through the main:

int[] numsMerge = {5,3,6,4,2,0,1}; System.out.println("Merge Sort:"); System.out.println("nums = " + Arrays.toString(numsMerge)); mergeSortPrint(numsMerge, 0, numsMerge.length-1); System.out.println();

It should return:

Merge Sort:

nums = [5, 3, 6, 4, 2, 0, 1]

nums = [3, 5, 6, 4, 2, 0, 1]

nums = [3, 5, 4, 6, 2, 0, 1]

........

nums = [0, 1, 2, 3, 4, 5, 6]

4. public statie void insertionsortPrint (int t numa) Create this method by copying and pasting the insertionsort method in Step 3 above and then adding the statement System.out.printl1n (nums+Arrays.tostring( at the end of the first for loop (right before the ) that ends the first for loop) nums)) S. public statie void mergeSort (int) numa, int left, int right) This method sorts the subarray nums (left..right] of the nums array into increasing order using the merge sort algorithm. Use the following pseudocode for this method: If left

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!