We have discussed Introduction to Binary Tree in set 1 and Properties of Binary Tree in Set 2. In this post, common types of Binary Trees are discussed.

The following are common types of Binary Trees.

**Full Binary Tree** A Binary Tree is a full binary tree if every node has 0 or 2 children. The following are the examples of a full binary tree. We can also say a full binary tree is a binary tree in which all nodes except leaf nodes have two children.

18 / \ 15 30 / \ / \ 40 50 100 40 18 / \ 15 20 / \ 40 50 / \ 30 50 18 / \ 40 30 / \ 100 40

**In a Full Binary Tree, number of leaf nodes is the number of internal nodes plus 1**

L = I + 1

Where L = Number of leaf nodes, I = Number of internal nodes

See Handshaking Lemma and Tree for proof.

**Complete Binary Tree:** A Binary Tree is a complete Binary Tree if all the levels are completely filled except possibly the last level and the last level has all keys as left as possible

The following are examples of Complete Binary Trees

18 / \ 15 30 / \ / \ 40 50 100 40 18 / \ 15 30 / \ / \ 40 50 100 40 / \ / 8 7 9

Practical example of Complete Binary Tree is Binary Heap.

**Perfect Binary Tree** A Binary tree is a Perfect Binary Tree in which all the internal nodes have two children and all leaf nodes are at the same level.

The following are the examples of Perfect Binary Trees.

18 / \ 15 30 / \ / \ 40 50 100 40 18 / \ 15 30

A Perfect Binary Tree of height h (where the height of the binary tree is the longest path from the root node to any leaf node in the tree) has 2^{h+1} – 1 node.

An example of a Perfect binary tree is ancestors in the family. Keep a person at root, parents as children, parents of parents as their children.

**Balanced Binary Tree**

A binary tree is balanced if the height of the tree is O(Log n) where n is the number of nodes. For Example, the AVL tree maintains O(Log n) height by making sure that the difference between the heights of the left and right subtrees is almost 1. Red-Black trees maintain O(Log n) height by making sure that the number of Black nodes on every root to leaf paths is the same and there are no adjacent red nodes. Balanced Binary Search trees are performance-wise good as they provide O(log n) time for search, insert and delete.

**A degenerate (or pathological) tree **A Tree where every internal node has one child. Such trees are performance-wise same as linked list.

10 / 20 \ 30 \ 40

**Source:**

https://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Check if a binary tree is subtree of another binary tree | Set 1
- Check if a binary tree is subtree of another binary tree | Set 2
- Convert a Binary Tree to Threaded binary tree | Set 1 (Using Queue)
- Convert a Binary Tree to Threaded binary tree | Set 2 (Efficient)
- Binary Tree to Binary Search Tree Conversion using STL set
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Binary Tree to Binary Search Tree Conversion
- Check whether a binary tree is a full binary tree or not
- Minimum swap required to convert binary tree to binary search tree
- Check whether a binary tree is a full binary tree or not | Iterative Approach
- Check whether a given binary tree is skewed binary tree or not?
- Difference between Binary Tree and Binary Search Tree
- Check if a binary tree is subtree of another binary tree using preorder traversal : Iterative
- Check whether a binary tree is a complete tree or not | Set 2 (Recursive Solution)
- Print Binary Tree levels in sorted order | Set 3 (Tree given as array)
- Check if the given binary tree has a sub-tree with equal no of 1's and 0's | Set 2
- Print Binary Tree levels in sorted order | Set 2 (Using set)
- Convert a Binary Tree into its Mirror Tree
- Convert an arbitrary Binary Tree to a tree that holds Children Sum Property