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$ **.

Dark Mode

1,000 views

1 vote

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

Answer 9

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$ **.

3

2 votes

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.

@_sonu I think you have wrongly taken the formula. In question its mentioned that complete tree with __ total __ 256 nodes. The height of complete binary tree is floor value (log n+1) with base 2. Hence height should be 8

Please refer underlined part of the image

0