Question: Assume we already have class for binary search tree called BinarySearchT, you have access to the following methods (assume they are coded) 1 public
Assume we already have class for binary search tree called BinarySearchT, you have access to the following methods (assume they are coded) 1 public class BSTNode { 2 public int key; 3 public E value; 4 public BSTNode left; 5 public BSTNode right; 6} 7 public class BinarySearchT { 8 private BSTNode root; 9 public void insert(int key, E value) {...} 10 public void delete(int key) {...} 11 public find(int key) {...} 12 } Java 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: 1. you should use a helper function 2. I would do it with recursion 3. the key and value has no effect on this 4. remember what is the definition of the height with respect the depths of nodes 5. 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
3.50 Rating (160 Votes )
There are 3 Steps involved in it
You can compute the height of a binary search tree recursively by calculating the height of its left ... View full answer
Get step-by-step solutions from verified subject matter experts
