Ask Question
16 July, 05:28

Write a program that finds the max binary tree height. (This Is an extremely short piece of code!)

+3
Answers (1)
  1. 16 July, 05:40
    0
    {

    if (root==NULL)

    return 0;

    int l_height=height (root->left); //calculating height of left subtree.

    int r_height=height (root->right); //calculating height of right subtree.

    return 1+max (l_height, r_height); //returning the maximum from left and right height and adding 1 height of root.

    }

    Explanation:

    The above written program is in C++. It find the height of a maximum height of the binary tree. The function uses recursion to find the height.

    First the left subtree's height is calculated then right subtree's then finding the maximum from both of them and adding 1 height of the root.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program that finds the max binary tree height. (This Is an extremely short piece of code!) ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers