Question: Assume we already have class for binary search tree called BinarySearchT , you have access to the following methods (assume they are coded) public class
Assume we already have class for binary search tree called BinarySearchT,
you have access to the following methods (assume they are coded)
public class BSTNode { public int key; public E value; public BSTNode left; public BSTNode right; } public class BinarySearchT { private BSTNode root; public void insert(int key, E value) { ... } public void delete(int key) { ... } public find(int key) { ... } } you are asked to only code a method public int treeH() to the BinarySearchT class that computes the height of the tree.
Hint: You can use a helper method.
Hints:
you should use a helper function
I would do it with recursion
the key and value has no effect on this
remember what is the definition of the height with respect the depths of nodes
you can use Math.max(a,b) that would return the max between a and b, but if you prefer, you also can do it with loops
Note: make sure the name of the method matches
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
