Understanding insertion at root


Insert at root is an operation where we insert a new node with the given value at the root of a given binary tree. The operation is simple as it does not involve any tree traversal and adds links to the existing tree. There are two cases to consider.

1. The tree is empty

If the given tree is empty, we can create a new node with the given value, which becomes the tree itself.

Liking the course? Check our discounted plans to continue learning.