Question: Can I get help with implementing a quick sort in my program? Starter Code: import java.util.Random; import java.util.Scanner; import java.util.Arrays; import java.util.Collections; import java.util.ArrayList; public

Can I get help with implementing a quick sort in my program?

Starter Code:

import java.util.Random; import java.util.Scanner; import java.util.Arrays;

import java.util.Collections; import java.util.ArrayList; public class RQS { public static int[] prepareData(int[] patients){ /* Data is prepared by inserting random values between 1 and 1000. Data items may be assumed to be unique. Please refer to lab spec for the problem definiton. */ // what is our range? int max = 1000; // create instance of Random class Random randomNum = new Random();

ArrayList list = new ArrayList(); for (int i=0; i

for (int i=0; i

return patients; } public static int[] sortArray(int[] patient_ids){ /* Add your logic below to sort the array.*/

return patient_ids; }

public static void main(String[] args) { System.out.println("Enter the no of patients:"); Scanner scan = new Scanner(System.in); int patients = scan.nextInt(); int[] patient_ids = new int[patients]; int[] patients_populated = prepareData(patient_ids);

/* The line below will print the output. Do not uncomment this lines. */ System.out.println("Unsorted:\t" + Arrays.toString(patients_populated));

/* Implement the sortArray method, so as to get the correct results.*/ int[] sorted_array = sortArray(patients_populated);

/* The line below will print the output. Do not uncomment this lines. */ System.out.println("Sorted:\t" + Arrays.toString(sorted_array));

} }

The output of the program should be generated using the ascending order format. Make necessary code modifications to this starter-code file. Read through the comments in the code file for additional information on the structure of the code. I could really use some help with this will give a thumbs up for anybody that can help.

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!