Binary Tree and types
Binary Tree and types
A binary tree is a tree data structure in which each parent node can have at most two children.
Each node of a binary tree consists of three items:
• data item
• address of left child
• address of right child
A complete binary tree is just like a full binary tree, but with two major differences
3. The last leaf element might not have a right sibling i.e. a complete binary tree doesn't
Complete Binary Tree has all levels completely filled with nodes except the last level and in the
last level, all the nodes are as left side as possible.
Interesting Fact: Binary Heap is an important use case of Complete Binary tree.
Interesting Fact: Total number of nodes in a Perfect Binary Tree with height H is 2^H — 1.
4. Balanced Binary Tree
Balanced Binary Tree is a Binary tree in which height of the left and the right sub-trees of every
node may differ by at most 1.
Interesting Fact: AVL Tree and Red-Black Tree are well-known data structure to
generate/maintain Balanced Binary Search Tree. Search, insert and delete operations cost O(log
n) time in that.
Interesting Fact: Height of a Degenerate Binary Tree is equal to Total number of nodes in that
tree.
Skewed Binary Tree
A skewed binary tree is a pathological/degenerate tree in which the tree is either dominated by
the left nodes or the right nodes. Thus, there are two types of skewed binary tree: left-skewed
binary tree and right-skewed binary tree.