BASICS OF RECURSION
Recursion is an alternative to iteration in making a function execute repeatedly.
Recurrence from Latin , re = back + currere = to run to happen again
Types of Recursion
I Direct recursion – Function calls itself from within itself.
II Indirect recursion – Two functions call one another mutually.
int abc( ) int abc( )
{ {
—-; —–;
abc( ); xyz( );
} }
int xyz( )
{
abc( );
——–;
}
Direct Recursion Indirect Recursion
Linear Recursion
Every possible chain of recursive calls must eventually reach a base case, and handling of each base case should not use recursion. A simple example of linear recursion is given .
Binary Recursion
It occurs when there are two recursive calls for each non base case.
Example is the problem to add all numbers in an integer array A.
Multiple Recursion
In it we make many recursive calls.
