Difference between "Complete binary tree", "strict binary tree","full binary Tree"?
Solution 1
A full binary tree (sometimes proper binary tree or 2-tree or strictly binary tree) is a tree in which every node other than the leaves has two children.
So you have no nodes with only 1 child. Appears to be the same as strict binary tree.
Here is an image of a full/strict binary tree, from google:
A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
It seems to mean a balanced tree.
Here is an image of a complete binary tree, from google, full tree part of image is bonus.
Solution 2
Perfect Tree:
x
/ \
/ \
x x
/ \ / \
x x x x
/ \ / \ / \ / \
x x x x x x x x
Complete Tree:
x
/ \
/ \
x x
/ \ / \
x x x x
/ \ /
x x x
Strict/Full Tree:
x
/ \
/ \
x x
/ \
x x
/ \
x x
Solution 3
There is a difference between a STRICT and FULL BINARY TREE.
1) FULL BINARY TREE: A binary tree of height h that contains exactly (2^h)-1 elements is called a full binary tree. (Ref: Pg 427, Data Structures, Algorithms and Applications in C++ [University Press], Second Edition by Sartaj Sahni).
or in other words
In a FULL BINARY TREE each node has exactly 0 or 2 children and all leaf nodes are on the same level.
For Example: The following is a FULL BINARY TREE:
18
/ \
15 30
/ \ / \
40 50 100 40
2) STRICT BINARY TREE: Each node has exactly 0 or 2 children.
For example: The following is a STRICT BINARY TREE:
18
/ \
15 30
/ \
40 50
I think there's no confusion in the definition of a Complete Binary Tree, still for the completeness of the post I would like to tell what a Complete Binary Tree is.
3) COMPLETE BINARY TREE: A Binary Tree is complete Binary Tree if all levels are completely filled except possibly the last level and the last level has all keys as left as possible.
For Example: The following is a COMPLETE BINARY TREE:
18
/ \
15 30
/ \ / \
40 50 100 40
/ \ /
8 7 9
Note: The following is also a Complete Binary Tree:
18
/ \
15 30
/ \ / \
40 50 100 40
Solution 4
Disclaimer- The main source of some definitions are wikipedia, any suggestion to improve my answer is welcome.
Although this post has an accepted answer and is a good one I was still in confusion and would like to add some more clarification regarding the difference between these terms.
(1)FULL BINARY TREE- A full binary tree is a binary tree in which every node other than the leaves has two children.This is also called strictly binary tree.
The above two are the examples of full or strictly binary tree.
(2)COMPLETE BINARY TREE- Now, the definition of complete binary tree is quite ambiguous, it states :- A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. It can have between 1 and 2h nodes, as far left as possible, at the last level h
Notice the lines in italic.
The ambiguity lies in the lines in italics , "except possibly the last" which means that the last level may also be completely filled , i.e this exception need not always be satisfied. If the exception doesn't hold then it is exactly like the second image I posted, which can also be called as perfect binary tree. So, a perfect binary tree is also full and complete but not vice-versa which will be clear by one more definition I need to state:
ALMOST COMPLETE BINARY TREE- When the exception in the definition of complete binary tree holds then it is called almost complete binary tree or nearly complete binary tree . It is just a type of complete binary tree itself , but a separate definition is necessary to make it more unambiguous.
So an almost complete binary tree will look like this, you can see in the image the nodes are as far left as possible so it is more like a subset of complete binary tree , to say more rigorously every almost complete binary tree is a complete binary tree but not vice versa . :
Solution 5
Concluding from above answers, Here is the exact difference between full/strictly, complete and perfect binary trees
Full/Strictly binary tree :- Every node except the leaf nodes have two children
Complete binary tree :- Every level except the last level is completely filled and all the nodes are left justified.
Perfect binary tree :- Every node except the leaf nodes have two children and every level (last level too) is completely filled.
kTiwari
Updated on December 21, 2020Comments
-
kTiwari over 3 years
I am confused about the terminology of the below trees, I have been studying the Tree, and I am unable to distinguish between these trees:
a) Complete Binary Tree
b) Strict Binary Tree
c) Full Binary Tree
Please help me to differentiate among these trees. When and where these trees are used in Data Structure?
-
0decimal0 almost 10 yearsYour complete tree example also fulfills the criteria of being a full binary tree so the difference is apparently blurred , in my opinion you might wanna give an example of a complete tree which is not a full binary tree and vice-versa , that would make the answer complete :)
-
0decimal0 almost 10 yearsYou cannot strictly say that "reverse is not possible " in fact your this very assumption is defied in the example of complete tree in the accepted answer ... you should rather say that may or may not be possible
-
mrida over 9 yearsif the depth of the binary is n the no. of nodes in the full binary tree is ( 2^n-1 ): but a full binary tree definition is a tree where every node is either a leaf or has two children. So the max possible no. of children is ( 2^n-1 ) but it may be less than that.
-
Saurabh Bhatia about 7 yearsThere is a difference between full binary tree and strictly binary tree. Refer to the answer: stackoverflow.com/a/32064101/5237727
-
RBT about 7 yearsBy perfect binary tree you mean full binary tree referred by the OP?
-
Keego almost 7 yearsYou're definition for a full binary tree is incorrect, that is the definition of a perfect binary tree. A full binary tree is synonymous with a strictly binary tree. (source: see strictly binary tree: faculty.cs.niu.edu/~mcmahon/CS241/Notes/bintree.html) (source: see perfect binary tree: slideshare.net/ajaykumarc137151/…)
-
BertKing almost 7 yearsoh, my god, I am confused just now,I will make sure of this. Many thanks.
-
Keego almost 7 yearsNo problem :) See the answer by @Lotus below, he nailed it. I just recommended edits for your answer to reflect this.
-
sfarbota almost 7 yearsAlso, while all complete trees are balanced trees, all balanced trees are not necessarily complete trees.
-
lolololol ol over 6 yearsWhat does it mean that every level is completely filled?
-
Sam I am says Reinstate Monica over 6 years@lololololol it means that all of the nodes that can possibly be in that level are present.
-
Joel Cunningham over 6 yearsOn the Complete tree, the "all nodes are as far left as possible" is a little confusing. I think this means in the last row, there will be no gaps if you do a level traverse from left to right. Once you hit a node on the second to last level with no left or right child, you know that's the last one.
-
neo over 5 yearsPerfect binary tree is both Strict/Full binary tree as well as Complete binary tree but vice versa may not be always true.
-
Pace over 5 yearsOne thing to keep in mind too is that there is some literature out there which uses "complete binary tree" and "nearly complete binary tree" (e.g. homepages.math.uic.edu/~leon/cs-mcs401-s08/handouts/…) and their definition of "complete binary tree" is actually what most would consider to be a "full binary tree". Unfortunately the Wikipedia page has this sentence which confused me terribly and I think is borrowing from this terminology
a heap is a specialized tree-based data structure which is essentially an almost complete[1] tree
-
Calvin Li about 5 years
-
Saurabh Bhatia about 5 years@CalvinLi The source is mentioned in the definition of FULL BINARY TREE. Here is a link of the pdf (pg 447 of the pdf) - o6ucs.files.wordpress.com/2012/10/…
-
Rose over 4 years@SaurabhBhatia, the last representation also holds true for the full binary tree. Correct me if I'm wrong. How can be one representation holds true for different varieties?
-
nkrivenko over 3 years> In this tree every non-leaf node has no child i.e. neither left nor right Non-leaf node has to have at least one children, else it is leaf node