I cant understand how the recursive case is going on
Can anyone please break it down and teach me step by step the whole recursive scene.
void buildtree(int a,int s,int e,int tree,int index){
if(s==e){
tree[index] = a[s];
return;
}
int mid = (s+e)/2;
buildtree(a,s,mid,tree,2index);
buildtree(a,mid+1,e,tree,2index+1);
tree[index] = min(tree[2index],tree[2index+1]);
return;
}
Cant understand the recursive case
Hi
you can watch this video https://www.youtube.com/watch?v=c5O7E_PDO4U&list=PLrmLmBdmIlpvyRmZhZxSMmSfAlKetBFYa it breaks down the code.
although a better video in your course is provided, watch that first if you haven’t
if you have doubt more:
contact me on whatsapp 8750354215 after 9pm .
you have few errors in your code i’m correcting this
void buildtree(int a,int s,int e,int tree,int index){
if(s==e){
tree[index] = a[s];
return;
}
int mid = (s+e)/2;
buildtree(a,s,mid,tree,2index+1);
buildtree(a,mid+1,e,tree,2index+2);
tree[index] = min(tree[2index+1],tree[2index+2]);
return;
}
Hi
If your doubt is cleared please mark it resolve in your online course ask doubt section.
Thanks!
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.