Question

Extend the Binary Search Tree ADT to include a basic public method getRoot that returns a reference to the root of the tree. If the tree is empty, the method should return null.

EXPERT ANSWER

The program below returns the reference of the root node with the help of getRoot() method. The other methods like the addLeft and addRight method set the left and right child of the tree using recursion.