Binary Search Trees (BST)

 

 

Problem #1:

Add the following methods in Tree.java and test the same in TreeTest.java:

a)     A method which takes the address of the root as the input and returns the maximum value in the BST (see solution below).

b)     A method which takes the address of the root as the input and returns the minimum value in the BST.

c)     A method which takes the address of the root and prints all the leaves in the BST. A leaf in a BST is a node whose left and right references are both equal to “null”.

d)     A method which takes the address of the root and an input search value as the input and prints a line stating if the BST contains the search value or not.

 

 

The above methods have been added to Tree.java:

·        Tree.java

·        Node.java will remain unchanged.