Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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