A binary tree is a tree that has at most 2 children for all the nodes. Since each element in a binary tree can have only 2 children, we call them the left and right child.
Types of Binary Tree
There are 5 types of Binary Tree: -
Full or Strict Binary tree.
A Binary tree is said to be a Full or Strict Binary Tree if all nodes have either 0 or 2 children.
Perfect binary tree
A Binary tree is said to be a Perfect Binary Tree if all internal nodes have exactly 2 children and all leaf nodes are on the same level.
Complete binary tree
A Binary tree is said to be a Complete Binary Tree if all levels are filled except possibly the last level and the Last level must have its key as left as possible.
Degenerate Tree
A Binary tree is said to be a Degenerate Tree if every parent node has exactly one child.
Skewed Tree
A skewed Tree is a degenerate tree where every parent node has exactly one child and is either dominated by the left nodes or the right nodes.
Skewed Tree has two types: -
- Left Skewed: All Nodes are on the left side.
- Right Skewed: All Nodes are on the right side.