To start with basics, it is very important to understand binary tree itself to understand different types of it.
A tree is a binary tree if and only if :-
– It has a root node , which may not have any child nodes (0 childnodes, NULL tree)
–Root node may have 1 or 2 child nodes . Each such node forms abinary tree itself
–Number of child nodes can be 0 ,1 ,2.......not more than 2
–There is a unique path from the root to every other node
Example :
X
/ \
X X
/ \
X X
Coming to your inquired terminologies:
A binary tree is a complete binary tree ( of height h , we take root node as 0 ) if and only if :-
Level 0 to h-1 represent a full binary tree of height h-1
– One or more nodes in level h-1 may have 0, or 1 child nodes
If j,k are nodes in level h-1, then j has more child nodes than k if and only if j is to the left of k , i.e. the last level (h) can be missing leaf nodes, however the ones present must be shifted to the left
Example :
X
/ \
/ \
/ \
X X
/ \ / \
X X X X
/ \ / \ / \ / \
X X X X X X X X
A binary tree is a strictly binary tree if and only if :-
Each node has exactly two child nodes or no nodes
Example :
X
/ \
X X
/ \
X X
/ \ / \
X X X X
A binary tree is a full binary tree if and only if :-
Each non leaf node has exactly two child nodes
All leaf nodes are at the same level
Example :
X
/ \
/ \
/ \
X X
/ \ / \
X X X X
/ \ / \ / \ / \
X X X X X X X X
/ \ / \ / \ / \ / \ / \ / \ / \
X X X X X X X X X X X X X X X X
You should also know what a perfect binary tree is?
A binary tree is a perfect binary tree if and only if :-
– is a full binary tree
– All leaf nodes are at the same level
Example :
X
/ \
/ \
/ \
X X
/ \ / \
X X X X
/ \ / \ / \ / \
X X X X X X X X
/ \ / \ / \ / \ / \ / \ / \ / \
X X X X X X X X X X X X X X X X
Well, I am sorry I cannot post images as I do not have 10 reputation. Hope this helps you and others!