Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Good evening to all here. I struggle hard to do this task and need serious help

ID: 3631286 • Letter: G

Question

Good evening to all here.
I struggle hard to do this task and need serious help to solve it.I've tried even a good while now but going nowhere and need help from anyone who can better than myself

It goes like this:

We should use the Comparator in the generic way, such as:

import java.util.Comparator;
public class CircleSorter_Color implements Comparator {<Circle>
public int compare (Circle c1, Circle c2) {
/ / Your implementation
}
}

Write a version of quicksort that takes an array of objects and a Comparator object as input to get the sorted array.
Signature of quicksort will be as under, with calls to the internal quicksort:

public static <E> void quicksort (E [] list,
Comparator <? super E> comparator) {
quicksort (list, 0, list.length - 1, comparator);
}

Make a Circle class, and a couple of implementations of the Comparator that sorts this class in different ways. An example call to the "regular" quicksort (using Comparable interface), and an example of quicksort with Comparator object is shown below. Circle is a simple class with a radius and color as data members.

public static void main (String [] args) {
Integer [] list = {2, 3, 2, 5, 6, 1, -2, 3, 14, 12};
quicksort (list);
for (int i = 0; <list.length; i + +) {
System.out.println (list [i] + "");
}
System.out.println ();
Employee [] List 1 =
{new Circle ("Red", 3),
new Circle ("Green", 8),
new Circle ("Blue", 12.5),
new Circle ("Yellow", 10);
new Circle ("Blue", 12), new Circle ("Yellow", 11),
};
quicksort (List1, new CircleColorComparator ());
for (int i = 0; <list1.length; i + +) {
System.out.println (List1 [i] + "");
} / / Sort even on area, and print results
}

Explanation / Answer

Ok rate this as lifesaver first. I am sick and tired of people taking advantage of me. I spend 30 minutes to one hour posting a solution and then they just take the answer and dont rate it. Inbox me once you have rated it and I will send you the solution.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote