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...


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.








Nov 27, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here