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:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started