0% found this document useful (0 votes)
0 views

Binary Tree and types

DSA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Binary Tree and types

DSA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Binary Tree

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

Types of Binary Tree

1. Full Binary Tree


Full Binary Tree is a Binary Tree in which every node has 0 or 2 children.
Interesting Fact: For Full Binary Tree, following equation is always true.

Number of Leaf nodes = Number of Internal nodes + 1

2. Complete Binary Tree

A complete binary tree is just like a full binary tree, but with two major differences

1. Every level must be completely filled

2. All the leaf elements must lean towards the left.

3. The last leaf element might not have a right sibling i.e. a complete binary tree doesn't

have to be a full binary tree.

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.

3. Perfect Binary Tree


Perfect Binary Tree is a Binary Tree in which all internal nodes have 2 children and all the leaf
nodes are at the same depth or same level.

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.

5. Degenerate(or Pathological) Binary Tree


Degenerate Binary Tree is a Binary Tree where every parent node has only one child node.

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.

You might also like