can u plz tell me where should i correct my code??
Delete node from bst
Ashish, the input format you are taking is not correct. In the question, you arent given the inorder and preorder arrays, rather you are given simple numbers and then you need to follow the native approach to build tree. You can follow the approach as :
node* insert(node* root, int d)
{
if (root == NULL)
{
node *temp = new node(d); //CHANGED
return temp;
}
if (d <= root->data)
{
root->left = insert(root->left, d);
}
else
{
root->right = insert(root->right, d);
}
return root;
}
https://ide.codingblocks.com/s/316484 ma’am now tree is buiding fine but not getting output after deletion
I have made some changes in your code… pls refer to the edited code : https://ide.codingblocks.com/s/321706
thank you so much for helping