A binary tree is a hierarchical data structure with nodes having at most two children, identified as left and right. There are several types of binary trees including full, perfect, complete, degenerate, skewed, and balanced trees, each defined by specific characteristics regarding the arrangement and number of children. The structure of a binary tree can be represented using linked lists with pointers for child nodes and a data element.
A binary tree is a hierarchical data structure with nodes having at most two children, identified as left and right. There are several types of binary trees including full, perfect, complete, degenerate, skewed, and balanced trees, each defined by specific characteristics regarding the arrangement and number of children. The structure of a binary tree can be represented using linked lists with pointers for child nodes and a data element.
Binary Tree:- A binary tree is a hierarchal data structure in which each node
has at most two children. The child nodes are called the left child and the right child. The linked list representation of a binary tree in which each node has three fields:-
Pointer to store the address of the left child
Data element Pointer to store the address of the right child
Types of Binary Trees:-
1. Full/Proper/Strict Binary Tree:- A binary tree is said to be a full binary
tree when each internal node has zero or two children.
2. Perfect Binary Tree:- A perfect binary tree is a special type of binary
tree in which all the leaf nodes are at the same level, and each internal node has two children. 3. Complete Binary Tree:- A binary tree is referred to as a complete binary tree when all of its levels are completely filled. The only exception is possibly the lowest level in which the nodes must lean as left as possible. In a complete binary tree, the nodes should be added from the left.
4. Degenerate or Pathological Tree:- A degenerate or pathological tree
is a type of binary tree in which each internal node has a single child, either the left child or the right child. 5. Skewed Binary Tree:- A binary tree is said to be a skewed binary tree if all of its internal nodes have exactly one child, and either left children or right children dominate the tree. In particular, there exist two types of skewed binary trees: left-skewed binary tree and the right-skewed binary tree.
6. Balanced Binary Tree:- A balanced binary tree is also a special type of
binary tree in which the difference of height between the left and the right subtrees for each node is at most one.