Delete Node from BST problem

suppose I make all the functions one that constructs the tree, one for perorder and one for inorder and store inorder in an arraylist but how to use this array list to make coonextion to rest of the nodes after deletion. ie. suppose n node is deleted then then we have to attach the node previous to it in inorder to its parent , how to do that using arralist of preorder?

@AbhishekAhlawat1102,
After you construct the tree and you have all the nodes in the right place.

There are three situations of deleting a node from binary search tree.

  1. The node to be deleted is a leaf node: It is the simplest case, in this case, replace the leaf node with the NULL and simple free the allocated space.

  2. The node to be deleted has only one child: In this case, replace the node with its child and delete the child node, which now contains the value which is to be deleted. Simply replace it with the NULL and free the allocated space.

  3. The node to be deleted has two children: It is a bit complex case compare to other two cases. However, the node which is to be deleted, is replaced with its in-order successor or predecessor recursively until the node value (to be deleted) is placed on the leaf of the tree. After the procedure, replace the node with NULL and free the allocated space.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.