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, 2011 Posted by Indika

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: Programming Tagged 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 Muzamil says

    February 14, 2022 at 3:32 pm

    Thanks

    Reply

Leave a Reply Cancel 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 Pancetta and Prosciutto

Difference Between Samsung Galaxy S4 and Sony Xperia Z, ZL

Difference Between Absolute Cost Advantage and Comparative Cost Advantage

Difference Between Absolute Cost Advantage and Comparative Cost Advantage

Difference Between Volumetric Pipette and Graduated Pipette

Difference Between Volumetric Pipette and Graduated Pipette

Difference Between Trust and Believe

Difference Between Trust and Believe

Latest Posts

  • What is the Difference Between de Quervain’s Tenosynovitis and Carpal Tunnel
  • What is the Difference Between Herniated Disc and Piriformis Syndrome
  • What is the Difference Between Spinal Stenosis and Spondylosis
  • What is the Difference Between Lip Flip and Lip Filler
  • What is the Difference Between Bone Spurs and Plantar Fasciitis
  • What is the Difference Between Tension Pneumothorax and Cardiac Tamponade
  • Home
  • Vacancies
  • About
  • Request Article
  • Contact Us

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