...

/

Deletion in a Binary Search Tree (Implementation)

Deletion in a Binary Search Tree (Implementation)

We will now write the implementation of the deletion function which covers all the cases that we discussed previously.

Introduction #

Let’s implement the delete function for BSTs. We’ll build upon the code as we cater for each case.

Also, note that the delete function in the BinarySearchTree class is simply calling the delete function in the Node class where the core of our implementation will reside.

1. Deleting an Empty Tree #

Let’s start with a skeleton function definition and cater for the first case. If the root does not exist, we return ...