The Wayback Machine - https://web.archive.org/web/20240530154425/https://www.geeksforgeeks.org/difference-between-full-and-complete-binary-tree/
Open In App

Difference between Full and Complete Binary Tree

Last Updated : 05 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A binary tree is a type of data structure where each node can only have two offspring at most named as “left” and “right” child.

A Binary Tree

There are different types of binary tree but here we are going to discuss about the difference of Complete binary tree and Full binary tree.

 Full Binary Tree:

A full binary tree is a binary tree in which all of the nodes have either 0 or 2 offspring. In other terms, a full binary tree is a binary tree in which all nodes, except the leaf nodes, have two offspring.

A Full Binary Tree

Let, i be the number of internal nodes
 n be the  total number of nodes
l be number of leaves
λ be number of levels

Then,

The number of leaves is (i + 1).
The total number of nodes is (2i + 1).
The number of internal nodes is (n – 1) / 2.
The number of leaves is (n + 1) / 2.
The total number of nodes is (2l – 1).
The number of internal nodes is (l – 1).
The number of leaves is at most (2λ – 1).

Complete Binary Tree:

A binary tree is said to be a complete binary tree if all its levels, except possibly the last level, have the maximum number of possible nodes, and all the nodes in the last level appear as far left as possible.

A Complete Binary Tree

There are 2 points that you can recognize from here,  

  1. The leftmost side of the leaf node must always be filled first.
  2. It isn’t necessary for the last leaf node to have a right sibling.

Check the following examples to understand the full and complete binary tree in a better way.

Example 1:

Neither complete nor full

  • Node C has just one child therefore, it is not a Full binary tree. 
  • Node C also has a right child but no left child, therefore it is also not a Complete binary tree. 

Hence, the binary tree shown above is neither complete nor full binary tree.

Example 2:

Full but not complete

  • All of the nodes have either 0 or 2 offspring, therefore, it is a Full binary tree. 
  • It is not a Complete binary tree because node B has no children whereas node C has children, and according to a complete binary tree, nodes should be filled from the left side.

Hence, the binary tree shown above is a Full binary tree and it is not a Complete binary tree.

Example 3:

Complete but not full

  • It is a complete binary tree as all the nodes are left filled.
  • Node B has just one child, therefore, it is not a full binary tree.

Hence, the binary tree shown above is a Complete binary tree and it is not a Full binary tree.

Example 4:

Complete and full

  • It is a Complete binary tree because all the nodes are left filled.
  • All of the nodes have either 0 or 2 offspring, therefore, it is a full binary tree.

Hence, the binary tree shown above is both a complete and a full binary tree.

S. No. Complete Binary Tree Full Binary Tree
1. In a complete binary tree, a node in the last level can have only one child. In a full binary tree, a node cannot have just one child.
2. In a complete binary tree, the node should be filled from the left to right. There is no order of filling nodes in a full binary tree.
3. Complete binary trees are mainly used in heap-based data structures. Full binary tree has no application as such but is also called a proper binary tree.
4. A complete binary tree is also called almost complete binary tree. A full binary tree also called  proper binary tree or 2-tree.
5 A complete binary tree must have the entire leaves node in the exact same depth.
 
In full binary tree leaf level not necessarily have to be in the same depth.
 

Previous Article
Next Article

Similar Reads

Check whether a binary tree is a full binary tree or not | Iterative Approach
Given a binary tree containing n nodes. The problem is to check whether the given binary tree is a full binary tree or not. A full binary tree is defined as a binary tree in which all nodes have either zero or two child nodes. Conversely, there is no node in a full binary tree, which has only one child node. Examples: Input : 1 / \ 2 3 / \ 4 5 Outp
8 min read
Check whether a binary tree is a full binary tree or not
A full binary tree is defined as a binary tree in which all nodes have either zero or two child nodes. Conversely, there is no node in a full binary tree, which has one child node. More information about full binary trees can be found here. For Example : Recommended PracticeFull binary treeTry It! To check whether a binary tree is a full binary tre
14 min read
Difference between Binary Tree and Binary Search Tree
Binary Tree Data Structure:A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right children.  [caption width="800"]Binary Tree Data Structure [/caption] Binary Search Tree Data Structure (BST):A binary search tree is a hierarchical
2 min read
Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
In this article, we will discuss the complexity of different operations in binary trees including BST and AVL trees. Before understanding this article, you should have a basic idea about Binary Tree, Binary Search Tree, and AVL Tree. The main operations in a binary tree are: search, insert and delete. We will see the worst-case time complexity of t
4 min read
Convert a Binary Tree into its Mirror Tree (Invert Binary Tree)
Given a binary tree, the task is to convert the binary tree into its Mirror tree. Mirror of a Binary Tree T is another Binary Tree M(T) with left and right children of all non-leaf nodes interchanged. [caption width="800"]Mirror Tree[/caption]Recommended PracticeMirror TreeTry It!The idea is to traverse recursively and swap the right and left subtr
17 min read
Construct Full Binary Tree using its Preorder traversal and Preorder traversal of its mirror tree
Given two arrays that represent Preorder traversals of a full binary tree and its mirror tree, we need to write a program to construct the binary tree using these two Preorder traversals.A Full Binary Tree is a binary tree where every node has either 0 or 2 children. Note: It is not possible to construct a general binary tree using these two traver
12 min read
Check whether a binary tree is a complete tree or not | Set 2 (Recursive Solution)
A complete binary tree is a binary tree whose all levels except the last level are completely filled and all the leaves in the last level are all to the left side. More information about complete binary trees can be found here. Example:Below tree is a Complete Binary Tree (All nodes till the second last nodes are filled and all leaves are to the le
10 min read
Difference between General tree and Binary tree
General Tree: In the data structure, General tree is a tree in which each node can have either zero or many child nodes. It can not be empty. In general tree, there is no limitation on the degree of a node. The topmost node of a general tree is called the root node. There are many subtrees in a general tree. The subtree of a general tree is unorder
2 min read
Difference between Binary Search Tree and AVL Tree
Binary Search Tree:A binary Search Tree is a node-based binary tree data structure that has the following properties: The left subtree of a node contains only nodes with keys lesser than the node’s key.The right subtree of a node contains only nodes with keys greater than the node’s key.The left and right subtree each must also be a binary search t
2 min read
Difference between Binary tree and B-tree
B-Tree : B-Tree is known as a self-balancing tree as its nodes are sorted in the inorder traversal. Unlike the binary trees, in B-tree, a node can have more than two children. B-tree has a height of logM N (Where ‘M’ is the order of tree and N is the number of nodes). And the height is adjusts automatically at each update. In the B-tree data is sor
7 min read
Article Tags :
Practice Tags :