Understanding tail recursion
Tail recursion is the exact opposite of head recursion. A recursive function where the function calls itself at the end of the code block, just before returning to the caller, is a tail-recursive function. It is often used to model problems where the processing in a function call does not depend on results from any deeper recursive call. It is also used when some information has to be passed down from the caller to the called function to process its result, and the solution is built from top to bottom.
Tail recursion pattern is the classification of problems that can be solved using tail recursion.
Loading Image
The solution is built from top to bottom before making recursive calls in tail recursion.
Liking the course? Check our discounted plans to continue learning.