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
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 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
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}))$
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.