2-3 Deletion of Element at Leaf Node
This lesson will cover the deletion operation in 2-3 Trees, discussing all four of the scenarios based on the position of the element that needs to be deleted.
Deletion Algorithm
The deletion algorithm also takes time and begins from the leaf node, just like an insertion. The deletion in 2-3 Trees is performed based on these scenarios:
Case 1: Element at Leaf
When the element which needs to be removed is present at the leaf node, we check how many keys are present in that node. The further divides the algorithm into two scenarios:
Leaf node has more than one key
If the leaf of the element to be deleted has more than one key, then simply delete the element.
Example: See the following example where the node has more than one key.
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.