Search⌘ K

Insertion

Explore how to insert a new key into a binary search tree by locating the proper leaf position and understand the associated time complexity. This lesson helps you grasp the insertion algorithm fundamentals in BSTs, preparing you for advanced binary tree operations.

We'll cover the following...

Algorithm

A new key is always inserted as a leaf. We search for the location for a new key as mentioned in the previous lesson and insert the new node when we reach the end.

Time Complexity: In the worst case, we traverse to the deepest node. So insertion time complexity is ...