Eg(pseudocode)
func(int x)
{
if(x>0){
print(before execution:x);
func(x-1);
print(after execution: x);
}
}
Call this function with x=5 Before execution n=5
Before execution n=4
Before execution n=3
Before execution n=2
Before execution n=1
After execution n=1
After execution n=2
After execution n=3
After execution n=4
After execution n=5
The output will appear like this.Before execution part is not suprising. It is pretty obvious. But after execution part is noteworthy for me specially.
I can naively guess that it is a call stack that is being used. And it is just popping the value from the top of the stack that was pushed earlier. But I am not exactly sure of the architecture of data structure that is being used and methodologies that are being followed at code and hardware level. As a CS enthusiast, it is my basic need to understand this. Hope to get some insights here.
austin-cheney•4h ago
shivajikobardan•3h ago
austin-cheney•2h ago