Delete in bst recursion

getting tle after running the program

Hey @guptashubham210a
Your code is correct there is one minor correction
On line 143 : it should be cin>>t
Also your input in in wrong format.
Try this: 1
7
5 3 2 4 7 6 8
3
2 3 5

@Kartikkhariwal1
getting tle for some case

Please Share your code

@Kartikkhariwal1

Hey @guptashubham210a
Do this changes in this part
node* root =build(n);node* deleted=root; //MAKE Deleted point to root
cin>>m;
while(m–){
cin>>d;
deleted=deleteinbst(deleted,d); //PASS deleted
}

Earlier u were getting runtime and not the , run time because if root node is deleted then if we call deleted(root) this causes segmentation error

@Kartikkhariwal1
but i am not calling any deleted(root) na so how?

@Kartikkhariwal1
It worked but I didn’t understood why we make deleted to point root early because I am not accessing root after deleting so why neither I am calling deleted(root);

I meant deleteinbst(root,d)
In this if value to be deleted is at root
Then next time when you call this again it will give u segmentation error because root node doesnt exist and its deleted

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.