On Wed, Jul 13, 2011 at 1:40 PM, [email protected] <
[email protected]> wrote:

>
> Guys i always have this doubt.Please tell me whether stack frames allocated
> for each recursive call will be cleared if we return in the middle of a
> recursive call?
>


In normal condition, the return statement will take the control to the
functions's caller, which might be the function itself if its a recursive
call. There is no way to return to the original caller, who called your
recursive function, without skipping the stack.

I think the only way to skip to the original caller, is by throwing an
exception from the recursive function, which is caught by the original
caller. The exception will unwind the stack till someone catches it.

--

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to