Deletion

In the lesson, we'll see how to delete a key from a BST.

Deletion

While removing a node from a BST, three cases are possible:

  1. Node is a leaf
  2. Node has only one child
  3. Node has two children

In any case, we could end up traversing the entire tree in case of a skewed binary tree. So, the time complexity is O(N)O(N).

Node is a leaf

In this case, the node can simply be removed from the tree.

Get hands-on with 1200+ tech skills courses.