## Code Avinya

Software Development Blogs

# What is Extended Binary Tree?

Before going deep drive to understand what is extended binary tree is, it is very important to get a little recap of what exactly a binary tree is.

So, the tree is a data structure that stores data in the form of a layer that looks exactly like an actual tree. And a tree with not more than two child nodes or exactly two child nodes( Node >= 2) is called a binary tree.

To get a better understanding of binary trees and their terminologies, read this blog.

So now let’s start with what is extended binary tree and its application.

## What is Extended Binary Tree Data Structure?

An Extended Binary tree is a regular binary tree where every parent node should have exactly 0 or 2 child nodes, and the leaf node should not have any extended child node.

- So we can say that this tree has either 0 or 2 child nodes.

- The extended binary tree is also known as a 2-Tree data structure.

## How to convert a regular binary tree into an extended binary tree?

A regular binary tree can be converted to an extended binary tree by replacing each empty or null subtree with a new node which is called an External node, so every subtree should have exactly two child nodes to become an extended binary tree.

**Extended Binary Tree Example:**

So, in the above first figure, we have a binary tree, and each node of that tree is referred to as INTERNAL NODE (represented as a circle). So, to make this binary tree to Extended binary tree (second figure), we will add an EXTERNAL NODE (represented as a square) where we don’t see exactly two child nodes for every parent node.

**Note: We don’t have to make any child node for an external node.**

## What is Internal Node and External Node?

- The nodes already present in the tree are known as Internal nodes.
- The node we add to the binary tree to make an extended binary tree is the External node.
- The Internal node should have exactly two child nodes. On the other hand, the External node has no child or extension nodes.

**Note: External Node=Internal Node+1;**

## Advantages and Disadvantages:

**Advantages of Extended Binary Trees:**

- Extended binary trees are more flexible than regular binary trees because they allow nodes to have more than two children.
- Extended binary trees provide more functionality than standard binary trees because of the extension nodes.
- Using different methods, such as arrays or linked lists, Extended binary trees can easily represent these data structures. So this makes this tree easier to store and access data.

**Disadvantages of Extended Binary Trees:**

- Extended binary trees are more complex than regular binary trees because of extension nodes. And because of this, it makes the searching or traversing operations and algorithms more challenging to understand and implement.
- Extended binary trees require extra memory storage to store extension nodes that can increase memory usage.
- Practically, these trees are used less than regular binary trees due to the absence of a wide range of pre-defined algorithms or libraries designed explicitly for this tree structure.

## Application**s:**

- Extended binary trees can represent organizational structures and generate organization charts.
- Extended binary trees play a vital role in indexing and search structures to enable efficient data retrieval.
- Network routing algorithms use Extended binary trees to route data packets across networks efficiently.
- File systems also use this data structure to organize directories and files.

## What is the difference between a binary tree and an extended binary tree?

In a regular binary tree, each node can have at most two children(node>=2). Extended binary trees enhance the capabilities of binary trees by allowing adding nodes to have more than two children via extension nodes.

## Is a complete binary tree and an extended binary tree are same?

No, complete and extended binary trees are not the same. In a complete binary tree, every tree level, except the last one, has the maximum number of internal nodes. And complete binary tree does not have any concept of extension nodes.

## Conclusion:

So, we can conclude that an *extended binary tree* transforms any regular binary tree into a complete binary tree with external nodes, which helps solve complex problems efficiently and effectively.

### About Us

Myself Bharath Choudhary, software developer at Oracle.

2021 NIT Warangal graduate.

### Categories

- About Companies (21)
- System Design (6)
- Uncategorized (36)

### Quick Contact

contact@codeavinya.com

Saturday – Sunday

10 AM – 5 PM

Follow Us :