Question: SOLUTION IN JAVA PLEASE sortNumbers.java: interface Comparator { public int compare(T a, T b); } abstract class ArraySort { public Comparator comparator; abstract public void

SOLUTION IN JAVA PLEASE

SOLUTION IN JAVA PLEASE sortNumbers.java: interface Comparator { public int compare(T a,

T b); } abstract class ArraySort { public Comparator comparator; abstract public

sortNumbers.java:

interface Comparator { public int compare(T a, T b); } abstract class ArraySort { public Comparator comparator; abstract public void iSort(T[] inArray); //abstract public T[] oSort(T[] inArray); public long iSortTimed(T[] inArray); { return 0; } public void setComparator(Comparator comparator) { this.comparator = comparator; } } class BubbleSort extends ArraySort { void iSort(T[] inArray) { print(inArray); }; //void oSort(T[] inArray) {}; void print(T[] a) { for (T t: a) { System.out.print(t); System.out.print(" "); } System.out.print(" "); } } public class sortNumbers { Integer[] iarray = new Integer[5]; iarray[0] = 1; iarray[1] = 3; iarray[2] = 3; iarray[3] = 6; iarray[4] = 4; BubbleSort bsorti = new BubbleSort(); bsorti.iSort(iarray); } 

Introduction The Second part of the assignment focuses on sorting plus empirical algorithm evaluation. You will experiment with the following three algorithms 1. Bubble sort; 2. Quick sort; and 3. Merge sort. Sorting In this section you will need to implement Bubble sort, Quick sort and Merge Sort algorithms by extending a base abstract class, You will start with the following abstract class public abstract class ArraySort abstract public void isort (T[] inArray) abstract public T[ oSort (T inArray) public long iSortTimed (T inArray). > public void setComparator (Comparator comparator) f > You must 1) complete this class and 2) extend this abstract class (to implement the three sorting algorithms) by implementing its abstract methods. Method iSort Performs in-place sorting. The input array is replaced by a sorted version, Method oSort Performs out-of-place sorting. It preserves the input array, and returns a new sorted array Method iSortTimed Performs in-place sorting and records the time it took to perform this sorting. Method setComparator Sets the comparator used by the sorting procedures. Comparator Interface It is important to emphasize that it is expected that your implementations will work with generic data type (T), so you need to provide a mechanism of comparing two generic values. You will implement a Comparator interface for the generic used in public interface Comparator public int compare (T a, T b); The only method that requires implementation is compare()The return value of compare(a,b) is defined as:-1 if a abstract public void isort (T[] inArray) abstract public T[ oSort (T inArray) public long iSortTimed (T inArray). > public void setComparator (Comparator comparator) f > You must 1) complete this class and 2) extend this abstract class (to implement the three sorting algorithms) by implementing its abstract methods. Method iSort Performs in-place sorting. The input array is replaced by a sorted version, Method oSort Performs out-of-place sorting. It preserves the input array, and returns a new sorted array Method iSortTimed Performs in-place sorting and records the time it took to perform this sorting. Method setComparator Sets the comparator used by the sorting procedures. Comparator Interface It is important to emphasize that it is expected that your implementations will work with generic data type (T), so you need to provide a mechanism of comparing two generic values. You will implement a Comparator interface for the generic used in public interface Comparator public int compare (T a, T b); The only method that requires implementation is compare()The return value of compare(a,b) is defined as:-1 if a

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!