Chapter 18: Problem 9
Convert classes TreeNode and Tree trom Fig. 17.17 into generic classes. Io insert an object in a Tree, the object must be compared to the objects in existing TreeNodes. For this reason, classes TreeNode and Tree should specify Comparable \(<\mathrm{E}>\) as the upper bound of each class's type parameter. After modifying classes TreeNode and Tree, write a test application that creates three Tree objects - one that stores Integers, one that stores Doubles and one that stores Strings. Insert 10 values into each tree. Then output the preorder, inorder and postorder traversals for each Tree.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.