Binary trees introduction and its types

a binary tree is a type of tree data structure, which doesn’t have more than two child nodes for one parent node. a binary tree contains a finite set of nodes

above tree has a three child nodes E,F,G to the parent node C,so there are 3 subnodes to the parent node, this is not a binary tree, but this can be called as tree

Types of binary trees#

• Full Binary Tree
• Complete Binary Tree
• Skewed Binary Tree

Full Binary Tree#

a full binary tree is a tree which each node has 2 child nodes or sub-nodes except leaves nodes

here, in the above picture, a tree is not a binary tree because B has only one child node D

Complete Binary Tree#

in a complete binary tree, every level except probably the last level is completely filled and all nodes are far left as possible

the last level may also be completely filled or it can be empty, if the last level is completely filled that tree can be called as a perfect tree too, like the above image

in the perfect tree, the leaf nodes will be at the same level and all other nodes have two child nodes

Skewed Binary Tree#

the tree in which each node is attached as a left child of a parent node is called left-skewed binary tree, to check to take A as a parent node now B is its child node and it is located at the left

the tree in which each node is attached as a right child of a parent node is called right-skewed binary tree, to check to take A as a parent node , B is its child node and it is located at the left

Last updated on by vishal devxo