This assignment makes use of the files contained in this zip file.
For this assignment you are to write a generic implementation of the heapsort algorithm using a generic implementation of the heap data type.
In the zip file there are two interfaces, PriorityQueue.java and Comparer.java . The first thing that you need to do is define a class Heap.java that implements the PriorityQueue interface. Your implementation of Heap.java should follow the outline of Section 9.3, pages 383-389, from Sedgewick's book and also the included Javadoc files for Heap.java and PriorityQueue.java .
After you have implemented and compiled Heap.java , you can implement the class HeapSort.java . Look at the included Javadoc file for HeapSort.java . There is only one method in this class and it is very short.
After you have implemented and compiled HeapSort.java , you can start working on getting TestHeapSort.java to compile. First implement the Comparer class called ComparerInteger.java . Use the included Javadoc for the Comparer.java interface as a guide. After your ComparerInteger.java is implemented and compiled, comment out the parts of TestHeapSort.java that do not make use of ComparerInteger.java (which is most of TestHeapSort ) and get what is left to compile and run. You should now have a working implementation of the heapsort algorithm. After heapsort is working with ComparerInteger.java , get each of the other Comparer classes to work. Then you have a generic version of the heapsort algorithm.
Turn in a zip file containing all of the original files from zip file plus your versions of Heap.java , HeapSort.java , ComparerInteger.java , and all of your other Comparer classes.
This assignment is due Monday, April 25.
|