Extended binary tree is a type of binary tree in which all the null sub tree of the original tree are replaced with special nodes called external nodes whereas other nodes are called internal nodes
Here the circles represent the internal nodes and the boxes represent the external nodes.
Properties of External binary tree
- The nodes from the original tree are internal nodes and the special nodes are external nodes.
- All external nodes are leaf nodes and the internal nodes are non-leaf nodes.
- Every internal node has exactly two children and every external node is a leaf. It displays the result which is a complete binary tree
Below is an example of making an extended binary tree in C++ by making all the external nodes as ‘-1’
-1 5 -1 2 -1 1 -1 3 -1 4 -1
Application of extended binary tree:
- Calculate weighted path length: It is used to calculate total path length in case of weighted tree.
Here, the sum of total weights is already calculated and stored in the external nodes and thus makes it very easier to calculate the total path length of a tree with given weights. The same technique can be used to update routing tables in a network.
- To convert binary tree in Complete binary tree: The above-given tree having removed all the external nodes, is not a complete binary tree. To introduce any tree as complete tree, external nodes are added onto it. Heap is a great example of a complete binary tree and thus each binary tree can be expressed as heap if external nodes are added to it.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Extended Disjoint Set Union on Trees
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Convert a Generic Tree(N-array Tree) to Binary Tree
- Check if a binary tree is subtree of another binary tree | Set 1
- Binary Tree to Binary Search Tree Conversion
- Check if a binary tree is subtree of another binary tree | Set 2
- Convert a Binary Tree to Threaded binary tree | Set 1 (Using Queue)
- Check whether a binary tree is a full binary tree or not
- Convert a Binary Tree to Threaded binary tree | Set 2 (Efficient)
- Minimum swap required to convert binary tree to binary search tree
- Check whether a given binary tree is skewed binary tree or not?
- Difference between Binary Tree and Binary Search Tree
- Binary Tree | Set 3 (Types of Binary Tree)
- Check if a binary tree is subtree of another binary tree using preorder traversal : Iterative
- Check whether a binary tree is a full binary tree or not | Iterative Approach
- Binary Tree to Binary Search Tree Conversion using STL set
- Convert a Binary Tree into its Mirror Tree
- Convert an arbitrary Binary Tree to a tree that holds Children Sum Property
- Check if a given Binary Tree is height balanced like a Red-Black Tree
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.