Can you please tell what the error is?
Build BST code coming out wrong
@MadHawk hey as input is in sorted order you tree building function is not right this question needs an array as input and a recursive function for building a tree think like a case of binary search you divide an array from mid.
here as you have to take an array break from mid
the root node will be treated as parent node
if(s>e){
return NULL;
}
int mid = (s+e)/2;
node*root = new node(arr[mid]);
root->left = arr2bst(arr,s,mid-1);
root->right = arr2bst(arr,mid+1,e);
return root;