Delete nodes in bst


what is the error in this code

hello @shiniagarwal25
a) build a normal bst , by inserting array element one by one.

b) image
here it should be
root->left=deletebst(root->left,data);

c) image
it should be->
image

https://ide.codingblocks.com/s/287121 madethe required changes still not getting the answer

image
again u r doing same mistake in these lines.
it should
root->left=insert(root->left,d)
same for root->right=insert(root->right,d)

still not getting right answer

pls share ur updated code

hello @shiniagarwal25

u were reading same array elemnts twice. one while taking input in array and one while building tree.

check ur updated code here->

1 Like