- Tail Recursion: A call is tail-recursive if nothing has to be
done after the call returns. I.e. when the call returns, the
returned value is immediately returned from the calling function.
More simply, tail recursion is when the recursive call is the last
statement in the function.
- If the recursive call occurs at the beginning of a method, it is
called a head recursion. Head Recursion: A call is head-recursive
when the first statement of the function is the recursive call.
|