Question: 1 Problem Description Instructions. You are provided the skeleton code named Sort2.java. The source file is available on Canvas in a folder named HW2. Please

 1 Problem Description Instructions. You are provided the skeleton code namedSort2.java. The source file is available on Canvas in a folder namedHW2. Please modify the skeleton code to solve the following tasks. Task

1 Problem Description Instructions. You are provided the skeleton code named Sort2.java. The source file is available on Canvas in a folder named HW2. Please modify the skeleton code to solve the following tasks. Task 1 (40 pts). Implement the Quick Sort algorithm as discussed in Lecture 4. (Hint: use the function checked.sorted to check if your output is indeed sorted.) Task 2 (40 pts). Implement the Counting Sort algorithm as discussed in Lecture 4. (Hint: use the function checked.sorted to check if your output is indeed sorted.) Task 3 (20 pts). Generate a report to discuss the time performance of the two algorithms. Compare it with their theoretical time complexity as discussed in the lecture. Plots and figures are encouraged to help draw the conclusion Optional Task 4 (100 pts Extra Credit). Implement the Heap Sort algo- rithm as discussed in Lecture 3. (Hint: use the function checked sorted to check if your output is indeed sorted.) package sorting: import java.util.*; public class Sort2 public static intfi merge_sort (int array, int p, int r) i *fill in your program return array: public static int[i merge (int array, int p, int a, int r) [ fill in your program return array: *n: the size of the output array * k: the maximum value in the array public static int[i generate random_array (int n, int k) 11st; List int arrayi Random rnd rnd new Random (System.currentTimeMills()); 11stnew ArrayList for (int1-1: 1 list; int [i arrayi for (int = 1; array[i]) return false: return true public static void print_array (int array) or (in 1-0 iarray.length: 1++) System.out.print (arrayi"," System.out.printin) public static void main (String args) [ TODO Auto-generated method stub System.out.printin ("Merge sort starts- for int n-100000: n

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!