1,573 views
1 votes
1 votes

What exactly is a Complete Binary Tree?

Different sources provide different definitions:

Source 1 :

A complete binary tree of depth d is the strictly binary tree all of whose leaves are at level d.

http://faculty.cs.niu.edu/~mcmahon/CS241/Notes/bintree.html

Source 2 :

In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes at the last level h.An alternative definition is a perfect tree whose rightmost leaves (perhaps all) have been removed.

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

Wiki says ::

Some authors use the term complete to refer instead to a perfect binary tree as defined above(Source2), in which case they call this type of tree an almost complete binary tree or nearly complete binary tree.

Which definition to follow ?

2 Answers

1 votes
1 votes
There is no standard definition ... they will clearly mention in exam what they actually mean by saying "a complete binary tree", incase if they didnt give always take that " a complete binary tree is a binary tree with all levels full except the last level where leaves are as left as possible..."
0 votes
0 votes
The second definition is correct.A complete binary tree has all levels full except the last level, which may or may not be full, at the same time leaves in the last level are as left as possible.

Also all leaves may not be at depth d, because if last level is not full, then some nodes at depth d-1 be leaf nodes.So first definition seems a little vague.

Related questions

1 votes
1 votes
0 answers
1
VS asked Dec 8, 2017
539 views
Balanced Binary Tree vs Complete TreeInsertion and Deletion is faster in which of the above 2 structures?
0 votes
0 votes
0 answers
2
–1 votes
–1 votes
1 answer
3
iarnav asked Jan 7, 2018
540 views
IS IT A CBT?
0 votes
0 votes
5 answers
4
radha gogia asked Sep 30, 2015
1,668 views
If I am given an array $X$ of $n$ distinct integers which is interpreted as a complete binary tree, so if the parent is at index $i$, then it's left child would be at ind...