1. If you are familiar with Java’s Comparable interface (Programming Project 11 on page 519), then rewrite one of the sorting methods so that it sorts an array of ods Comparable objects. You may choose selectionsort, insertionsort, mergesort, quicksort, or heapsort. For example, with selectionsort, you would have the specification shown here:
Programming Project 11 page 519
Java has a generic interface called Compara. A class that implements the Comparable interface must have a method with this specification:
Write a generic class for a bag of Compara objects, where the objects are stored in a binary search tree. The tree itself should use the BTNode class from Figure 9.10 on page 490.
The first line of your new bag class should be:
This tells the Java compiler that the ComparableTreeBag is a generic class, but that any instantiation of the generic type parameter E must implement the Compara interface.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here