I have this doubt since a long time..plz resolve

While going through recursion when the value returned is null from both rs and ls then we compute the result and uske baad we are returning the the value,where is this value returned to and next thing i want to ask is after returning this how will i go upward in the tree to other nodes without returning the root…

@garganshul151 hey bro ,after each call when recursion is completed and value is returned through base case the value return to the function call means where the function is called the value will return to that place ,after whole recursion is completed the value is returned to the function call in main,dry run this with call stack and push each call with arguments in stack and you will get it.

bhai ye smjh nhi aa rtha]

bhai ek chiz btao yr…ki iss q m first call m jab function k last m leaf node ki value return hgi main m uske baad fir main se kya call aegi, kya same root value aegi main se jo ki parent roothai

@garganshul151 hey bhai ,main me to ans return hoga,dekho main se call hui function ko ,fir uske andr aye fir base case check hue ager nhi hai to further recursion cal hui left pr aur right pr ,to aise assume kro ki right recursion ne apko ans lake dedia right subtree ka ,similiarly left ne ladia apko ans woh apne lefta dn right me store kraya hai now work on root ,jo ki apko maximum nikalna hai,hota ye hai ki jab and ki recursion call khtm hoti hai to ans apka wahi return hota hai jha se call hui.eg
func()
{
base case
left=func(left)
right=func(right)
}
upr eg me func main se call hua fir left me call hui,fir left rec puri hui to ans apna left variable me agya ab right me cal hogi and right me ans ajayega return krne pr control right pr ayega ,hope you get it.

bhai ek baat nhi aa rahi smjh ki agar apke vale example m right k niche kuch code h to find some result then jaisa apne kha ki phle left ka pura hga ok,uske baad fir left subtree m hi hum jub leaf node par aenge to code execute hoga jo ki right k niche likha hai then fir jab ye value main mein return hogi to root kya aaega hmare paas agli baar vo btao plz

@garganshul151 bhai woh value main me return nhi hogi right recursion ki ,wo wahi rerurn hoga jha se call kia tha ,root pr call hui fir left me call hui ,now left ki recursion call hogi aur return hogi to wo yhi return hogi jha call kia hao ,aise hi right ki bhi wahi ,fir hm left right se result nikalenge aur return krenge jo akhir me return hoga woh main me jauegi jo final ans hoga.