We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi, tree height in the example is correctly defined.
it calculated as n = n-1 where n is no. of nodes.
For ex. if no. of nodes is 4 then no. of edges will be 3 and that will be the max height.
No. of edges which is always less than the no. of nodes that is how it is used to calculate height of binary tree.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Height of a Binary Tree
You are viewing a single comment's thread. Return to all comments →
Hi, tree height in the example is correctly defined. it calculated as n = n-1 where n is no. of nodes. For ex. if no. of nodes is 4 then no. of edges will be 3 and that will be the max height.
No. of edges which is always less than the no. of nodes that is how it is used to calculate height of binary tree.