Build bst doubt


can you please tell me the problem in my code.

hey @Aryanomar00, you need to build balanced BST not ordinary BST, so you have make central point of array as root.
here is the logic
node* build(int arr,node root,int s,int e)
{
if(s>e)
{
return NULL;
}
int mid=(s+e)/2;
root=new node(arr[mid]);
root->left=build(arr,root->left,s,mid-1);
root->right=build(arr,root->right,mid+1,e);
return root;
}
Initial value of s=0 and e=N-1