Question: Write the program in Java pls public class Sorting{ public static void MergeSort(int[] A){ // TODO: Implement the MergeSort } public static void QuickSort(int[] A){

Write the program in Java pls public class Sorting{ public static void MergeSort(int[] A){ // TODO: Implement the MergeSort } public static void QuickSort(int[] A){ // TODO: Implement the QuickSort } private static void fillRandom(int[] A) { // TODO: Fill the given array with random integers between 1 and 1 million } private static void verifySorted(int[] A){ // TODO: Return successfully if the array is sorted property, otherwise throw a runtime exception } public static void main(String[] args){ int[] sizes = {20_000, 40_000, 60_000, 80_000, 100_000, 120_000, 140_000, 160_000, 180_000, 200_000}; for(int s : sizes){ int[] ints = new int[s]; System.out.println("Testing sorting procedures on an array of lenth " + s + ":"); // Test and time the MergeSort implementation fillRandom(ints); long startMerge = System.currentTimeMillis(); Sorting.MergeSort(ints); long mergeTime = System.currentTimeMillis() - startMerge; System.out.printf(" The MergeSort took %d ms ", mergeTime); verifySorted(ints); // Test and time the QuickSort implementation fillRandom(ints); //TODO: time the QuickSort implementation as above verifySorted(ints); System.out.println(" "); } } }

thank you.

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!