Introduction to Recursion
Recursion is a powerful tool which can sometimes provide elegant solutions to complex programming problems. A function is called recursive if a statement within the body of a function calls the same function again and again. When solving a problem through recursion two conditions must be satisfied:
1. The problem must be expressed in recursive manner.
2. There must be a condition which stops the recursion otherwise there would be a stack overflow problem.
There are two types of recursion methods:
1. Direct Recursion: In direct recursion, a function calls itself for a number of times until a particular condition is satisfied.
2. Indirect Recursion: In Indirect recursion, a function A calls another function B, function B calls function C and function C calls back to function A.