Answers for "how to find the height of a bst c++"

C++
1

height of bst cpp

// Find height of a tree, defined by the root node
int tree_height(Node* root) {
    if (root == NULL) 
        return 0;
    else {
        // Find the height of left, right subtrees
        left_height = tree_height(root->left);
        right_height = tree_height(root->right);
          
        // Find max(subtree_height) + 1 to get the height of the tree
        return max(left_height, right_height) + 1;
}
Posted by: Guest on October-10-2021

Code answers related to "how to find the height of a bst c++"

Browse Popular Code Answers by Language