search
Log In
0 votes
249 views

The height of a binary tree is defined as the number of nodes in the longest path from root to the leaf node. Let X be the height of a complete binary tree with 256 nodes. Then the value of X will be
Answer 9

 

in DS 249 views
3

https://www.geeksforgeeks.org/relationship-number-nodes-height-binary-tree/

If there are n nodes in a binary tree, the maximum height of the binary tree is n-1 and minimum height is $\left \lfloor log\ 2n \right \rfloor$ .

1 Answer

1 vote

Read carefully what it is saying :- The height of a binary tree is defined as the number of nodes in the longest path from root to the leaf node. i.e. if node is 3 with (height 2) then height = 3 (a/c to question).

basically it is saying with node = 1 height = 1.

now, for complete binary tree h= ceil(log(n+1)-1) [with height starting from h=0 with node=1.]

ceil(log(256+1)-1=8

hence for this question 8+1= 9.

Related questions

1 vote
1 answer
1
483 views
If the average depth of a node in an $n$-node binary search tree is $O(\log{n})$, then the height of the tree is $O(n\log{n})$ $O(n)$ $O(\log{n})$ $O(\sqrt(n\log{n}))$
asked Dec 25, 2017 in DS Rohit Gupta 8 483 views
2 votes
1 answer
2
3.3k views
What's the difference between Binary tree height, level and depth? Sometimes it's confusing! Does there definition change according to question also, if mentioned?
asked Jan 18, 2016 in DS Shashank Chavan 3.3k views
0 votes
0 answers
3
244 views
A weight balanced tree is a binary tree in which for each node, the no. of nodes in the left subtree is atleast half and at most twice the no. of nodes in the right sub tree. So how to approach for forming a recurrence for finding the height of this weight balanced binary tree ?
asked Jan 11, 2016 in DS radha gogia 244 views
3 votes
5 answers
4
5k views
The number of nodes of height $h$ in any $n$-element heap is ________. $h$ $2^{h}$ ceil $\left[\frac{n}{2^{h}}\right]$ ceil $\left[\frac{n}{2^{h+1}}\right]$ Answer is given as D, But I think it should be C. Because, even if you take height=1 then possible nodes are 3 and 2.
asked Jan 19, 2016 in DS Tushar Shinde 5k views
...