https://ide.codingblocks.com/s/188556 it’s giving TLE , I doesn’t found any sort method
Build BST problem
Hi @Jitu748,
update ur base case in function buildbst to
if(s==e){
node *n=new node(arr[s]);
node *root=n;
return root;
}
if(s>e){
return NULL;
}
after updating ur base case, it will work.
We will have to add above case. This is because:
consider a case-> build tree for array {1,2}
Now u find mid to be 1.
node left=build(arr,0,0-1} which is not feasible if the above case is not added.
node right=buildbst{arr,0+1,1} which is feasible.
Hope this clears ur doubt.