Question: java work please. This is the Starting code: System.out.println( Array 1: ); int[] array1= {14, 28, 17, 74, 32 ,16, 5, 9, 41}; for (int

java work please.

java work please. This is the Starting code: System.out.println(" Array 1: ");

This is the Starting code:

System.out.println(" Array 1: ");

int[] array1= {14, 28, 17, 74, 32 ,16, 5, 9, 41};

for (int i = 0; i

System.out.print( array1[i]+", ");

}

System.out.println();

insertionSort1(array1);

System.out.println(" ");

System.out.println(" Array 2: ");

int[] array2= {2, 14, 17, 23, 31, 36, 42, 47, 49};

for (int i = 0; i

System.out.print(array2[i]+ ", ");

}

System.out.println();

insertionSort1(array2);

System.out.println(" ");

System.out.println(" Array 3: ");

int[] array3= {97, 81, 74, 68, 62, 54, 50, 41, 13};

for (int i = 0; i

System.out.print( array3[i]+", ");

}

System.out.println();

insertionSort1(array3);

;

}

public static void insertionSort1 (int[] array){

int temp;

int j;

for (int i = 1; i

temp = array[i];

j= i-1;

while ((j>-1) && (array[j] > temp)) {

array[j+1] = array[j];

j--;

}

array[j+1] = temp;

System.out.println(Arrays.toString(array));

}

}

You will need to download the file Lab 8a Starting Code.zip from Pilot for this lab. The code in the zip file creates three ArrayLists, each of which is filled with one million values. The program then sorts each of the lists and outputs the number of milliseconds this takes (on my computer it takes around 1800 milliseconds, i.e. 1.8 seconds). Your task for this lab is to modify this program so that it processes sorts each ArrayList in a separate thread. This should speed up the program considerably, as the results below show. IMPORTANT: Your program still needs to accurately measure the time it takes to process all of the files. One way to do this is to create one thread to sort each list and then call each thread's join method before you get the end time. single thread Sorting took 2589 ms Multi-threaded Sorting took 1426 ms *Note that your values may not exactly match these - they depend on the computer you are using and the particular random values generated for the lists; however, the multithreaded value should be noticeably smaller than the single thread version

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!