...

/

Deletion in Binary Search Tree

Deletion in Binary Search Tree

In this lesson, we are going to learn how nodes are deleted in binary search trees. We will take a look at a few node deletion scenarios and what to do in each one.

Introduction #

In this lesson, we are going to study how a node is deleted in a BST. In general, to delete a node in a BST, you will search for it and once found, you will reallocate its left and right subtree, (if present) and then you’ll remove to be deleted node from the BST.

However, to make things simpler, we’ve identified four possible cases involved in BST node deletion. We’ll tackle each one separately:

  1. Deleting in an empty tree
  2. Deleting a node with no children, i.e., a leaf node.
...