Saturday, February 2, 2008


Recursion means self-refrence. A recursive function is function whose defination is based upon itself. It means that a recursive function is a function which have the statements calling itself. We can say that the effect of recursion is same as the looping and the Iteration.

Types of Recursion.

1. Linear Recursion
2. Binary Recursion
3. Mutual Recursion
4. Tail Recursion
5. Nested Recursion
Now we will briefly discuss about the Types of recursion.
Linear Recursion:-
A function that only makes a single call to itself each time the function runs.
Eg. Factorial
Binary Recursion:-
Some recursion don't have just one call they have two or more function with two recursive call are refer to the binary recursion of function.
intchoose(int n, int k)
if (k==0//n==k)
return (1);
return (choose (n-1,k) + choose (n-1,k-1));
Mutual Recursion:-
A recursive function don't neccessary to call itself some recursive function works in pairs or even in larger group.
int is_even(unsigned, int n)
if (n==0)
return (1);
else return (is_odd(n-1));
int is_odd (unsigned intn)
return (is_even (n));
Nested Recursion:-
A nested recursions, the argument to the recursive function is the recursive function itself.
int ackerman(int m, int n)
if (m==0)
return (n+1);
else if (n==0)
return (ackerman (m-1,1));
else return (ackerman (m-1, ackerman(m,m-1));
Tail Recursion:-
A recursion procedure where a recursive call is the last action to be taken by the function.
int gcd (int m, int n)
int r;
if (m
return gcd (m,n);
if (r==0) return (n);
return (gcd (n,r));
Narendra Kumar Khoiya
MITS College Gwalior.

No comments: