Ask Question
9 October, 20:01

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

+4
Answers (1)
  1. 9 October, 21:36
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers