Rewrite the min and max methods from Self-Check Problem 12 so that they will work on a
Question:
Rewrite the min and max methods from Self-Check Problem 12 so that they will work on a binary search tree. The methods should take advantage of the fact that the tree is sorted and should not examine nodes unless necessary.
Data from Self Problem 12
Write methods called min and max that could be added to the IntTree class and that return the smallest and largest values in the tree, respectively. For example, if a variable called tree stores the values shown in Self-Check Problem 5, the call of tree.min() should return –2 and the call of tree.max() should return 94. If the tree is empty, the methods should throw an IllegalStateException.
Data from Self Problem 5
Write the elements of the given tree in the order in which they would be seen by a preorder, inorder, and postorder traversal.
Step by Step Answer:
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp