Recursion issue , , , , , , , , , , , ,,,, , , , ,

es case m recursion kese chla can you explain this.

@Nitin-Mishra-2380486738834604
in recursive tree there are three state for every node pre,in and post.
so we divide the code into different regions of recursive function let suppose fn();

{
PRE AREA
}
fn();
{
IN AREA
}

fn();
{

POST AREA;
}

mera doubt ye h ki jb extrem left m pauch jata exp. Inorder(root.left) toh ye right switch kese krta h if you explain through stack then i can understand better.

@Nitin-Mishra-2380486738834604
1
/ \
2 3
/
4

suppose we have a tree like this and let our recursive stack be st:
we start at 1
st:1<-top
st:1,2<-top
st:1,2,4<-top
now left child of 4 is null therefore we hit the base case and return
st:1,2,4<-top
at this point we are at in area of node 4
we print 4
now call for the right child of 4 which is null again and we hit the base case and return from there
after both left and right call of 4 we retrace back to 2
st:1,2<-top
at this point we are at in area of node 2
we print 2
now we check for the right child of 2 which is null again and return back
st:1<-top

at the point we are at in area of node 1
we print node 1
and call for the right child
st :1,3<-top
which check left child of node 3 which is null again and return back from there
now we are at in area of node 3
we print node 3
now call for right child which is null and we return back
st:1<-top
we have finally reached the post area of node 1 and we return from here
st:<-top