Compare the Difference Between Similar Terms

Difference Between

Home / Technology / IT / Programming /Difference Between Complete Binary Tree and Full Binary Tree

Difference Between Complete Binary Tree and Full Binary Tree

May 28, 2011Posted byIndika

Complete Binary Tree vs Full Binary Tree

Binary tree is a tree where each node has one or two children. In a binary tree, a node cannot have more than two children. In a binary tree, children are named as “left” and “right” children. The child nodes contain a reference to their parent. A complete binary tree is a binary tree in which every level of the binary tree is completely filled except the last level. In the unfilled level, the nodes are attached starting from the left-most position. A full binary tree is a tree in which every node in the tree has two children except the leaves of the tree.

What is Full Binary Tree?

Full binary tree is a binary tree in which every node in the tree has exactly zero or two children. In other words, every node in the tree except the leaves has exactly two children. Figure 1 below depicts a full binary tree. In a full binary tree, the number of nodes (n), number of laves (l) and the number of internal nodes (i) is related in a special way such that if you know any one of them you can determine the other two values as follows:

1. If a full binary tree has i internal nodes:

– Number of leaves l = i+1

– Total number of nodes n = 2*i+1

2. If a full binary tree has n nodes:

– Number of internal nodes i = (n-1)/2

– Number of leaves l=(n+1)/2

3. If a full binary tree has l leaves:

– Total Number of nodes n=2*l-1

– Number of internal nodes i = l-1

What is Complete Binary Tree?

As shown in figure 2, a complete binary tree is a binary tree in which every level of the tree is completely filled except the last level. Also, in the last level, nodes should be attached starting from the left-most position. A complete binary tree of height h satisfies the following conditions:

– From the root node, the level above last level represents a full binary tree of height h-1

– One or more nodes in last level may have 0 or 1 children

– If a, b are two nodes in the level above the last level, then a has more children than b if and only if a is situated left of b

What is the difference between Complete Binary Tree and Full Binary Tree?

Complete binary trees and full binary trees have a clear difference. While a full binary tree is a binary tree in which every node has zero or two children, a complete binary tree is a binary tree in which every level of the binary tree is completely filled except the last level. Some special data structures like heaps need to be complete binary trees while they don’t need to be full binary trees. In a full binary tree, if you know the number of total nodes or the number of laves or the number of internal nodes, you can find the other two very easily. But a complete binary tree does not have a special property relating theses three attributes.

Related posts:

Difference Between Java and JavaScript Difference Between Procedures and Functions in Programming Difference Between JSF2 and Seam3 Difference Between Ajax and Microsoft Silverlight Difference Between Encapsulation and Abstraction

Filed Under:ProgrammingTagged With:Binary tree,child nodes,complete binary tree,full binary tree,leaves,nodes,root node

About the Author:Indika

Indika, BSc.Eng, MSECE Computer Engineering, PhD. Computer Science, is an Assistant Professor and has research interests in the areas of Bioinformatics, Computational Biology, and Biomedical Natural Language Processing.

Comments

  1. Muhammad Muzamilsays

    February 14, 2022 at 3:32 pm

    Thanks

    Reply

Leave a ReplyCancel reply

Your email address will not be published.Required fields are marked*

Request Article

Featured Posts

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and SARS

Difference Between Coronavirus and SARS

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Covid 19

Difference Between Coronavirus and Covid 19

You May Like

Difference Between Serology and Immunology

Difference Between Serology and Immunology

Difference Between Summer Jeans and Winter Jeans

Difference Between Paracellular and Transcellular Diffusion

Difference Between Paracellular and Transcellular Diffusion

Difference Between Faith and Trust

Difference Between Faith and Trust

Difference Between Samsung Galaxy Tab and Apple iPad

Difference Between Samsung Galaxy Tab and Apple iPad

Latest Posts

  • What is the Difference Between Aquagenic Urticaria and Aquagenic Pruritus
  • What is the Difference Between Astringent and Toner
  • 食管炎和酒吧之间的区别是什么rett’s Esophagus
  • What is the Difference Between Alcohol Ink and Resin Dye
  • What is the Difference Between Hyperparathyroidism and Hyperthyroidism
  • What is the Difference Between Pearlescent and Iridescent
  • Home
  • Vacancies
  • About
  • Request Article
  • Contact Us

Copyright © 2010-2018Difference Between. All rights reserved.Terms of Useand Privacy Policy:Legal.