Description:This is a Program to Prevent Deletion of nodes having 2 degrees in the Binary Search Tree.
The approach will be as follow::
First, we will Construct the Binary Search Tree and insert some nodes
After Consrtucting this BST we can observe the nodes
0 Degree nodes -> 40, 75, 100, 150
1 Degree nodes -> No nodes
2 Degree nodes -> 95 55 110
So the Program is to prevent deletion of 2 degrees nodes (i.e 95, 55, 110 )
LOGIC::
we will check if the root's right child is NULL and the root's left child is NULL?
if yes then that node is having 0 degrees.
we will check if the root's right child is NULL or the root's left child is NULL?
if yes then that node is having 1 degree.
so perform deletion on both of these cases only.
else don't perform the deletion on the node simply return by giving the message.
Here is the sample code for more clarification.
Comments