Wrong output/////

please check

The approach you are using in insertinBST function is wrong…you have to convert your array into bst by the following approach as :
node *arrtoBST(int ar[1001],int start,int end)
{
if(start>end)
{
return NULL;
}
int mid=(start+end)/2;
node *root=new node(ar[mid]);
root->left=arrtoBST(ar,start,mid-1);
root->right=arrtoBST(ar,mid+1,end);
return root;
}

1 Like

yes it works fine now, thankyou