Question: import java.util.Arrays; public class MergeSort extends ConsoleProgram { /* * Do not make changes to this method! */ public void run() { int[] array1 =

 import java.util.Arrays; public class MergeSort extends ConsoleProgram { /* * Do

not make changes to this method! */ public void run() { int[]

array1 = {9, 8, 7, 6, 5, 4, 3, 2, 1}; int[]

array2 = {5, 6, 4, 8, 9, 7, 3, 1, 2}; System.out.print("First

import java.util.Arrays;

public class MergeSort extends ConsoleProgram { /* * Do not make changes to this method! */ public void run() { int[] array1 = {9, 8, 7, 6, 5, 4, 3, 2, 1}; int[] array2 = {5, 6, 4, 8, 9, 7, 3, 1, 2}; System.out.print("First array: "); System.out.println(Arrays.toString(array1)); System.out.print("Second array: "); System.out.println(Arrays.toString(array2)); System.out.println();

// sort first array mergeSort(array1); // sort second array mergeSort(array2);

System.out.print("First array sorted: "); System.out.println(Arrays.toString(array1)); System.out.print("Second array sorted: "); System.out.println(Arrays.toString(array2)); } /* * Merge sort takes in an array and sorts it. */ public static void mergeSort(int[] arr) { if (arr.length

array: "); System.out.println(Arrays.toString(array1)); System.out.print("Second array: "); System.out.println(Arrays.toString(array2)); System.out.println(); // sort first array

RUN CODE TEST CASES ASSIGNMENT DOCS GRADE MORE 10 points Status: Not Submitted Mergesort is a complicated algorithm, but how complicated is it? In this exercise, we'll be taking our example code from before and adding a cool feature: at every recursive step, print out to the console what the two halves are that are going to be merged together. O 8.7.4: Explore Merge Sort 1 import java.util.Arrays; 2 public class MergeSort extends ConsoleProgram 4- 5 /* * Do not make changes to this method! */ public void run() 9- int[] array1 = (9, 8, 7, 6, 5, 4, 3, 2, 1}; int[] array2 = (5, 6, 4, 8, 9, 7, 3, 1, 2}; 10 %3D 11 12 System.out.print("First array: "); System.out.printin(Arrays.toString(array1)); System.out.print("Second array: "); System.out.println(Arrays.toString(array2)); System.out.println(); 13 14 15 16 17 18 // sort first array mergeSort(array1); // sort second array mergeSort(array2); 19 20 21 22 23 System.out.print("First array sorted: "); System.out.println(Arrays.toString(array1)); System.out.print("Second array sorted: "); System.out.printin(Arrays.tostring(array2)); 24 25 26 27 28 29 30 * Merge sort takes in an array and sorts it. */ public static void mergeSort(int[] arr) 31 32 33 34- if (arr,length

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!