Binary Tree Data Structure and Its Types
What is Binary Tree Data Structure?
A binary tree is a type of tree in which each parent node have at most two child nodes. Each node of a binary tree has three items.
1. Data item
2. Address if a left child
3. Address of the right child
Types of Binary tree
1. Full Binary tree
A full binary tree is a type of binary tree in which each parent node have either two or no child nodes. Here 1 has 2 and 3 child nodes. 3 don't have any child nodes.
2. Perfect Binary Tree
A perfect Binary tree is a type of binary tree in which each parent node have exactly two child nodes and all leaf nodes are present at some level. Here 1 has 2 and 3 child nodes and 4,5,6,7 leaf nodes are present at some level.
3. Complete Binary tree
In a complete binary tree, all the levels are filled.
All leaf elements must lean towards the left in a tree structure.
The last leaf element might not have the right sibling.
4. Balanced Binary Tree
A balanced binary tree is a type of binary tree in which the height of the left and right subtree for each node is balanced, meaning it is either 0 or 1. Here the height of the left subtree is 2 and the height of the right subtree is 1 and their difference is 1.
5. Degenerate or pathological tree
A degenerate or pathological tree is a tree in which each node has only one child, either on the left or right side.
6. Skewed Binary Tree
A skewed binary tree is a pathological or degenerate tree in which the tree is either dominated by the left nodes or right nodes. Thus, there are two types of skewed binary trees: left-skewed binary trees and right-skewed binary trees.