Prove that in a binary tree with n elements the hight of the
Solution
Binary tree is a tree with the propery that each node has atmost 2 children. so it means either 0 or 2.
depth of a node is defined as length of path from root to that node.
Maximum depth of a binary tree is equal to height of the tree.
The maximum number of nodes that we can have at some level i will be equal to 2 to the power of i. ie; i=2i
At level 0maximum number of nodes is 20 is 1
At level 1 maximum number of nodes is 21 is 2
.
.
..
....
At level h maximum number of nodes is 2h
h is the height of the binary tree
ie; 20 + 21 + 22 ......... +2h
=> 2h+1 - 1
n is the number of nodes in a Binary Tree then n=2h+1 -1
Because if height is h number of nodes will be 2 to the power of (h+1)
2h+1 = n+1
h=log2(n+1) - 1
log2n.
A perfect Binary tree is always a complete Binary tree.
![Prove that in a binary tree with n elements, the hight of the tree is greater than or equal to [log_2(n)]. Prove that in a complete binary tree with n elements Prove that in a binary tree with n elements, the hight of the tree is greater than or equal to [log_2(n)]. Prove that in a complete binary tree with n elements](/WebImages/34/prove-that-in-a-binary-tree-with-n-elements-the-hight-of-the-1098889-1761580159-0.webp)