Question
Write the following two generic methods using quick sort. The first sorts the elements using the Comparable interface, and the second uses the Comparator interface.
Write the following two generic methods using quick sort. The first sorts the elements using the Comparable interface, and the second uses the Comparator interface. Below, you will find and outline of the source code you need to complete this program.
public static
void quickSort(E[ ] list)
/* Include your code here */
public static
Comparator super E> comparator)
// Code goes here
Your program should all fit into one file and include the following driver program:
public class FirstName_LastName_Test2 {
public static void main(String[ ] args) {
Integer[ ] list = {2, 3, 2, 5, 6, 1, -2, 3, 14, 12};
quickSort(list);
for (int i = 0; i < list.length; i++) {
System.out.print(list[i] + " ");
}
System.out.println();
Circle[ ] list1 = {new Circle(2), new Circle(3), new Circle(2),
new Circle(5), new Circle(6), new Circle(1), new Circle(2),
new Circle(3), new Circle(14), new Circle(12)};
quickSort(/* You need to include the relevant parameter list here */);
for (int i = 0; i < list1.length; i++) {
System.out.print(list1[i] + " ");
}
}
/* Your other methods
will be included here*/
}
/* Your other classes
all included in the same file */
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