Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 void quickSort(E[ ] list,

Comparator 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions