Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

x.Hmt case number of comparisons in searching a bst is equal to its height - the

ID: 3619013 • Letter: X

Question

x.Hmt case number of comparisons in searching a bst is equal to its height - the number of levels in a tree. Write a recursive member function height() for class template BST to determine the height of the BST. This is the header file and need help pretty soon too..

* BST.h contains the declaration of class template BST.
   Basic operations:
     Constructor: Constructs an empty BST
     empty:       Checks if a BST is empty
     search:      Search a BST for an item
     insert:      Inserts a value into a BST
     remove:      Removes a value from a BST
     inorder:     Inorder traversal of a BST -- output the data values
     graph:       Output a grapical representation of a BST
   Private utility helper operations:
     search2:     Used by delete
     inorderAux: Used by inorder
&nb

Explanation / Answer

Can somemone tell me if this is right.... int BST::TREE_HEIGHT(TreeNode tn){if (tn==NULL){return 0;}else {return 1 + max(TREE_HEIGHT(tn.leftChild), TREE_HEIGHT(tn.rightChild));}}