Next: Put it all together
Up: Assignment 10
Previous: Fix the performance issues
As an intermediate step toward the grade-sheet sorter, we're
going to make a generic version of Heap and test it using a
simple integer Sorter.
- Copy the Comparable class definition from the Priority
Queue assignment. We're going to adapt Heap to work with
Comparable items and create a simple class that is a member of
the Comparable abstract class.
- Make a new class named HeapItem with a single integer as an
instance variable. It should implement Comparable (and provide
methods named compareTo and toString). See PQItem for an
example of how to do this.
- Compile and run the three class definitions so that they
work again, generating 100 random numbers, inserting them into
the Heap, then removing and printing them.