Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a full binary tree and a complete binary tree?

A complete binary tree by my understanding can have incomplete nodes in the last level of the tree. What is a full binary tree? What is the difference?

like image 582
praxmon Avatar asked Oct 27 '25 05:10

praxmon


2 Answers

A full binary tree (sometimes proper binary tree or 2-tree) is a tree in which every node other than the leaves has two children.

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.

Here's the source for these descriptions and a picture for reference: http://web.cecs.pdx.edu/~sheard/course/Cs163/Doc/FullvsComplete.html

like image 106
Raevik Avatar answered Oct 30 '25 02:10

Raevik


Perfect Binary Tree: 1. All the Internal nodes must having two children. 2. All the leaf nodes are at the same level.

Example :

         A1
     B1       B2
  C1    C2  C3  C4

Complete Binary Tree: All the levels are completely filled except possibly the last level

Example :

         A1
     B1       B2
  C1    C2  C3  C4
D1  D2 D3 

Full Binary Tree: Simply Every node has 0 or 2 children.

Example :

         A1
     B1       B2
  C1    C2  C3  C4
D1  D2 

Do update if the answer is aggree

like image 29
Tamil.S Avatar answered Oct 30 '25 03:10

Tamil.S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!