Tag Archives: Recursion and Tail Recursion

Recursion and Tail Recursion

A function that calls itself is known as recursive function. This technique is known as recursion. A physical world example would be to place two parallel mirrors facing each other. Any object in between them would be reflected recursively.

How does recursion work in programming?

Here, the recurse() function is called from the body of recurse() function itself. Here’s how this program works.


Here, the recursive call continues forever causing infinite recursion. To avoid infinite recursion, if…else (or similar approach) can be used where one branch makes the recursive call and other doesn’t.

Continue reading Recursion and Tail Recursion

Follow and like us: