node* build(int a[],int s,int e,int n){
int mid=s+e/2;
if(s>e || e>n-1 ||s<0){
return NULL;
}
node *root=new node(a[mid]);
root->left=build(a,s,mid-1,n);
root->right=build(a,mid+1,e,n);
return root;
}
whats the prblm in this code
node* build(int a[],int s,int e,int n){
int mid=s+e/2;
if(s>e || e>n-1 ||s<0){
return NULL;
}
node *root=new node(a[mid]);
root->left=build(a,s,mid-1,n);
root->right=build(a,mid+1,e,n);
return root;
}
whats the prblm in this code
mid=(si+ei)/2;
brackets are important
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.