Deletion from a Binary Search Tree

1. Deletion of a leaf node is easy.  For example, if a leaf node is left child, we set the left child field of its parent to NULL and free the node.  

2. The deletion of a non-leaf node that has only a single child is also easy.  We erase the node and then place the single child in the place of the erased node.  


3. When we delete a non-leaf node with two children, we replace the node with either the largest element in its left sub-tree or the smallest elements in its right sub-tree.  Then we proceed by deleting this replacing element from the sub-tree from which it was taken.


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments:

Thanks
Mukesh Rajput