In this assignment you will be implementing and testing all three sort algorithms: Merge Sort , Quick Sort , and Heap Sort .
In additions, you will also be writing a driver to test the sorting algorithms and you will be measuring the test times
of each sort by using the TestTimes class that you enhanced for Homework 4.
Finally, you will be analysing and comparing the performance of the three sort algorithms based on the type of array that was being sorted and the run times you computed.
You will copy the TestTimes class that you enhanced in Homework 4 to the
project you are using for this assignment.
You will write the MergeSort.java class which will inherit from
TestTimes.java and implement the
Sort Interface
using the
Merge Sort
algorithm. The interface may be downloaded from
SortInterface.java
You can see the Merge Sort Java Documentation here.
Please note that your sort method must measure the run time and add it to the
TestTimes class by using the addTestTime() method.
You will write the QuickSort.java class which will inherit from
TestTimes.java and implement the
Sort Interface
using the
Quick Sort
algorithm. The interface may be downloaded from
SortInterface.java
You can see the Quick Sort Java Documentation here.
Please note that your sort method must measure the run time and add it to the
TestTimes class by using the addTestTime() method.
For your implementation of QuickSort, you must have three different ways of choosing
the pivot as specified by the PivotType enum
which will be defined in QuickSort.
You will write the HeapSort.java class which will inherit from
TestTimes.java and implement the
Sort Interface
using the
Heap Sort
algorithm. The interface may be downloaded from
SortInterface.java
You can see the Heap Sort Java Documentation here.
Please note that your sort method must measure the run time and add it to the
TestTimes class by using the addTestTime() method.
You will write the Driver.java class which will implement the
Driver Interface
. The interface may be downloaded from
DriverInterface.java
Please note that, in addition to implementing the DriverInterface, you are also required to write
your own public static main(String[] args) method in Driver.java.
Your main() method will have to call the runSort() method to sort each of the following array types
ten times for each sort algorithm:
Integers.
Integers.
Integers.
Integers.
Integers.
Integers.
Integers.
Integers.
Integers.
Integers.
For each call to the runSort() method to sort an ArrayType using a
SortType ten times, your
main() method will produce the following output:
ArrayType,Array Size--------------------- Run 1 Run 2 Run 3 Run 4 Run 5 Run 6 Run 7 Run 8 Run 9 Run 10 Average Micro Micro Micro Micro Micro Micro Micro Micro Micro Micro Micro Seconds Seconds Seconds Seconds Seconds Seconds Seconds Seconds Seconds Seconds Seconds ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- MergeSort QuickSort FirstElement QuickSort RandomElement QuickSort MidOfFirstMidLastElement HeapSort
Run 1 Run 2 Run 3 Run 4 Run 5 Run 6 Run 7 Run 8 Run 9 Run 10 Average
Kilo Bytes Kilo Bytes Kilo Bytes Kilo Bytes Kilo Bytes Kilo Bytes Kilo Bytes Kilo Bytes Kilo Bytes Kilo Bytes Kilo Bytes
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
MergeSort
QuickSort FirstElement
QuickSort RandomElement
QuickSort MidOfFirstMidLastElement
HeapSort
Using the tables you created by running Driver.main(), copy your results and graphs into a Microsoft Word document and answer the following questions using 1-3 complete sentences for each question:
Please submit the completed assignment on the
Mimir Platform Website
.
You must submit your .java files as a zip file of only the classes and
interfaces specified above.
Please submit your analysis on Blackboard as a typed Microsoft Word file (.docx). No other forms of submission will be accepted.