************************** I want to add at the codes bellow a heap sort method and print from 100...
Question:
************************** I want to add at the codes bellow a heap sort method and print from 100 to 20,000 **************************
Please use java code
Random rnum = new Random(); for(int n = 100; n <= 20000; n = n+100){ double totalTime = 0; for(int i = 1; i <= 5; i++){ //declare an array and fill it with random numbers int[] numArray = new int[n]; for(int j =0 ; j < n; j++){ numArray[j] = rnum.nextInt(); } //apply quick sort algorithm on the array double start = System.nanoTime(); quickSort(numArray, 0, numArray.length-1); double end = System.nanoTime(); //Calculate the time it takes to sort the array double time = end-start; //Calculate the total time it takes to sort 5 arrays of the same size totalTime = totalTime + time; } // Calculate the average and convert it from nano seconds to seconds double avg = (totalTime/5)/1000000000; // Convert to scientific notation NumberFormat numFormat = new DecimalFormat("0.##E0"); System.out.println("Quick Sort Average Time For Size " + n + " In Scientific Notation: " +numFormat.format(avg)); } }