can anyone give me pseudo code for deletion of two child node in binary search tree.please explain it also.any example will be great. reply soon thanks in advance asked 13 Jul '13, 14:50

C++ implementation :
node Delete(node root, int data) { if(root == NULL) return root; else if(data < root>data) root>left = Delete(root>left,data); else if (data > root>data) root>right = Delete(root>right,data); else { ///Case 1: No child if(root>left == NULL && root>right == NULL) { delete root; root = NULL; } ///Case 2: One child else if(root>left == NULL) { struct node temp = root; root= root>right; delete temp; } else if(root>right == NULL) { struct node temp = root; root = root>left; delete temp; } ///case 3: 2 children else { node *temp = FindMin(root>right); root>data = temp>data; root>right = Delete(root>right,temp>data); } } return root; } answered 09 Nov '16, 08:54
