Neocortex 🧠

Search

Search IconIcon to open search

Deleting From A Binary Search Tree

Last updated Jan 1, 2022 Edit Source

Deleting from a binary search tree can be a tricky process since we want to sustain the BST property of the tree upon deletion. We can split the deletion of a node into three cases depending on how many children that node has.

# No Children

Just remove the node.

# One Child

Replace the node with its child.

# Two children

In this case, you have two choices:

All these operations can be done in $O(log(n))$ time.


Interactive Graph