Lately I have been implementing the standard Data Structures in Computer Science using the C Programming Language. These have the minimal functions to demonstrate the basic usage.
Going forward I will be adding more and also try to explain these.
As of now the list includes:
In the Binary Search Tree program the delete node functionality hasn’t been implemented fully.
The basic algorithm has been presented though which is as follows:
Algorithm to delete a Node from Binary Search Tree (BST)
1. Find the Node in the BST.
2. If Node is a Leaf, then go ahead and delete it.
3. If not find the “in-order successor / predecessor”. Say we use the in-order successor Node_S.
4. Swap the node with Node_S. Now delete Node_S and if it has any children then update the pointers.
For Step 3 we can find wither the minimum node in the right sub tree or the maximum node in the left sub tree.