...

/

Deletion in Binary Search Tree (Implementation)

Deletion in 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.

1. Deleting an empty tree #

Let’s start with a skeleton function definition and cater for the first case. We return false if the root is NULL.

Press + to interact
Delete(Node* currentNode,int value) {
if(root==NULL)
return false;
}

2. val not found #

We search for the tree for the data given, and if it’s not ...

Access this course and 1400+ top-rated courses and projects.