You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem Statement :- To find the height of the binary tree. The height of a binary tree is the number of edges between the tree's root and its furthest leaf.
Input: :- The first line contains an integer n, the number of nodes in the tree.
Next line contains n space separated integer where ith integer denotes node[i].data.
Example:-
Input:-
7
3 5 2 1 4 6 7
Output:-
3
Approach:-
We can use a recursive function , of type integer ,with base condition being to return 0 when the current node is leaf node. Else we will call the function recursively to the left , then the right and at the end return the MAX of left subtree and right subtree and add 1 to it.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!
Problem Statement :- To find the height of the binary tree. The height of a binary tree is the number of edges between the tree's root and its furthest leaf.
Input: :- The first line contains an integer n, the number of nodes in the tree.
Next line contains n space separated integer where ith integer denotes node[i].data.
Example:-
![ss](https://user-images.githubusercontent.com/77778242/136328779-bcdc97fc-98a0-4087-9578-7bd2e7c94e6e.png)
Input:-
7
3 5 2 1 4 6 7
Output:-
3
Approach:-
We can use a recursive function , of type integer ,with base condition being to return 0 when the current node is leaf node. Else we will call the function recursively to the left , then the right and at the end return the MAX of left subtree and right subtree and add 1 to it.
The text was updated successfully, but these errors were encountered: