Insertion in Binary Tree
We can insert a node anywhere in a binary tree by inserting the node as the left or right child of any node or by making the node as root of the tree.
Algorithm to insert a node in a Binary Tree:
- Check if there is a node in the binary tree, which has missing left child. If such a node exists, then insert the new node as its left child.
- Check if there is a node in the binary tree, which has missing right child. If such a node exists, then insert the new node as its right child.
- If we don’t find any node with missing left or right child, then find the node which has both the children missing and insert the node as its left or right child.
Introduction to Binary Tree – Data Structure and Algorithm Tutorials
Binary Tree is a non-linear data structure where each node has at most two children. In this article, we will cover all the basics of Binary Tree, Operations on Binary Tree, its implementation, advantages, disadvantages which will help you solve all the problems based on Binary Tree.
Table of Content
- What is Binary Tree?
- Representation of Binary Tree
- Types of Binary Tree
- Operations On Binary Tree
- Insertion in Binary Tree
- Traversal of Binary Tree
- Deletion in Binary Tree
- Searching in Binary Tree
- Auxiliary Operations On Binary Tree
- Implementation of Binary Tree
- Complexity Analysis of Binary Tree Operations
- Advantages of Binary Tree
- Disadvantages of Binary Tree
- Applications of Binary Tree
- Frequently Asked Questions on Binary Tree
Contact Us