Question: The file Sort.java, available in the course website on Desire 2 Learn, defines the Sort interface. Classes that implement the sort interface are capable of

The file Sort.java, available in the course website on Desire2Learn, defines the Sort interface. Classes that implement the sort interface are capable of sorting arrays of Comparable objects and counting the numbers of compares used to do the sorting.
The Sort interface defines two methods: void sort( Comparable [] a );
This method sorts the array a in ascending order, smaller items come first and larger items come later.
long getCompares();
This method returns the number of compares used in the sort.
Write four classes that implement the Sort interface. Name your classes InsertionSort, SelectionSort, BubbleSort, and QuickSort. Put your classes in the engi3255.sort package. Your classes must use the algorithms defined in the files InsertionSortstd.java, SelectionSortstd.java, BubbleSortstd.java, and QuickSortstd.java. These are made available to you in the course website on Desire2Learn. However, you must modify the provided code to count compares and to implement the Sort interface. Don't change the workings of the algorithms as this may cause your compare counts to be wrong.

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 Programming Questions!