Please explain how the return statement functions for a simple recursive parse of a trie
CASE A:
if (true) push &stack; //push path result onto a stack
else{
if (terminating condition true) return;
else {
condition 1 recursion to next node
condition 2 recursions to next node
...
condition n recursion to next node
}
recursion to next path;
}
CASE B:
if (true) {
push &stack; //push path result onto a stack
return;
}else{
if (terminating condition true) return;
else{
condition 1 recursion to next node
condition 2 recursion to next node
...
condition n recursion to next node
}
recursion to next path;
}
Case A is working fine for me. But, I don't understand what happens after the result is pushed to the stack. How does 'it' know to terminate those paths?