Question: PLEASEEE HELPPPP!!! You must write the code to perform the benchmarking of the two algorithms that you selected. You do not have to write the
PLEASEEE HELPPPP!!!

You must write the code to perform the benchmarking of the two algorithms that you selected. You do not have to write the sorting algorithms yourself, you may take them from some source, but you must reference your source.
(THE TWO I CHOSE ARE SELECTION AND QUICK SORT)
It should also randomly generate data to pass to the sorting methods. It should produce 40 data sets for each value of n, the size of the data set and average the result of those 40 runs. The exact same data must be used for both sorting algorithms. It should also create 12 different sizes of data sets. Choose sizes that will clearly demonstrate the trend as n becomes large.
I HAVE PUT WHAT I HAVE SO FAR BUT IM SO CONFUSED. PLEASE EXPAIN ANY ADDITIONS I REALLY WANT TO UNDERSTAND IT!
import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Random; import java.util.stream.IntStream; import javax.swing.*; import javax.swing.table.DefaultTableModel;
import javax.swing.*; import javax.swing.table.DefaultTableModel; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner;
public class Report {
private static final int NUM_OF_DATASET_SIZES = 12; private static final int NUM_OF_RUNS = 40;
public static void main(String[] args) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Select the input file"); int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); Scanner scanner; try { scanner = new Scanner(selectedFile); } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(null, "File not found", "Error", JOptionPane.ERROR_MESSAGE); return; } int[] datasetSizes = new int[NUM_OF_DATASET_SIZES]; int[][] counts = new int[NUM_OF_DATASET_SIZES][NUM_OF_RUNS]; long[][] times = new long[NUM_OF_DATASET_SIZES][NUM_OF_RUNS]; for (int i = 0; i
import java.util.Random;
abstract class AbstractSort { int count = 0; long startTime, endTime;
abstract void sort(int[] data);
void startSort() { count = 0; startTime = System.nanoTime(); }
void endSort() { endTime = System.nanoTime(); }
void incrementCount() { count++; }
int getCount() { return count; }
long getTime() { return endTime - startTime; } } //SelectionSort.java class SelectionSort extends AbstractSort { void selectionSort(int array[]) { int size = array.length;
for (int step = 0; step
for (int i = step + 1; i
// To sort in descending order, change > to
//QuickSort.java
class QuickSort extends AbstractSort { void sort(int[] data) { quickSort(data, 0, data.length - 1); }
private void quickSort(int[] data, int low, int high) { if (low
private int partition(int[] data, int low, int high) { int pivot = data[high]; int i = low - 1; for (int j = low; j
private void swap(int[] data, int i, int j) { int temp = data[i]; data[i] = data[j]; data[j] = temp; } } }
PLEASE HELP!! THANK YOU IN ADVANCE!
Some feedback I got from it was
The methods in the QuickSort class should not be static, and you need a helper method that is only passed the array to get the quick sort started.
You are missing the main class BenchmarkSorts. It needs to call the sorting algorithms repeatedly with different data sets. You need 12 different sizes of arrays. The method startSort should be called before the calling the sort and endSort after it completes. The sort methods should call incrementCount whenever a significant operation is executed. Once the sort completes getTime and getCount should be called to obtain the count and elapsed time.
Try to incorporate a main class into your program.
The benchmarking program must be written to conform to the following design
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
