BINARY TREE
fig. b similar binary tree
Equivalent Binary tree
In fig. c , at level k, there can be maximum 2^k nodes. therefore,
level 0 can have 2^0=1 node.
level 1 can have 2^1=2 nodes.
level 2 can have 2^2=4 nodes and so on.
Strictly Binary tree
A binary is called Strictly binary tree if all the non leaf nodes of the tree contains exactly two children.
It means , every non-leaf nodes contains left and right sub-tree.
It is also known as 2- tree or full Binary tree or extended binary tree.
It contains exactly 2n-1 nodes.
fig.e strictly binary tree
BINARY TREE PROPERTIES:
- A Binary tree with n nodes has exactly n-1 edges.
fig.1 binary tree
In the above fig. 1, number of nodes(n) are 15
number of edges= n-1=15-1=14
2. Every node except the root node has exactly one parent.
In the above fig. 1, A is the root node having no parent but rest nodes having only one parent i.e 3 has parent 1, 5 has parent 2.
3.There is exactly one path connecting any two nodes in the tree.
In the above fig. 1, you can see there is only one path between 0 to 1 or 1 to 3.
4. The maximum number of nodes at level ‘l’ of a binary tree is 2l-1
In the above fig. 1, level 1 has only one node 2^(1-1)=2^0=1
level 2 has 2 nodes 2^(2-1)=2^1=2 and so on.
5. Maximum number of nodes in a binary tree of height ‘h’ is 2h – 1.
In the above fig. 1, height of binary tree is 4(starting from 1 ,2,3,4)
Apply formula, Total number of nodes in a binary tree is 2^(4)-1=15
6. The number of leaf nodes in a complete binary tree is (n+1)/2
In the above fig. 1, number of nodes is 15
number of leaf nodes= (15+1)/2= 8 i.e node 7 to 14.
7. In a complete binary tree, number of external nodes= number of internal + 1
In the above fig. 1, number of internal nodes are 7 i.e 0 to 6
number of external nodes are 8 i.e 7 to 14