Question - Explain how new data can be inserted into the tree?
Answer -
The following are the steps that you need to follow to insert the data into the tree:
- First of all, check whether the data is unique or not ( i.e. check whether the data that you are going to insert doesn’t already exist in the tree).
- Then check if the tree is empty. If the tree is empty then all you need to do is just insert a new item into the root. If the key is smaller than that of a root’s key then insert that data into the root’s left subtree or otherwise, insert the data into the right side of the root’s subtree.