Question: 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,

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.

19 47 63 23 -2 94 55 28

19 47 63 23 -2 94 55 28

Step by Step Solution

3.32 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public int min if overallRoot throw new private int min IntTreeNode root if rootle... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!