Recursion : A function that calls itself is called recursive function. int fact(int N) { if(N==1) return 1; //termination condition else return N * fact(N-1); } ----------------------------------------- QUESTION : Write a recursive function of two ints arguments M,N (M,N > 0) Function should return M^N. int MyPower(int M,int N) { if(N==1) return M; else return M * MyPower(M,N-1); } QUESTION : Function should return the int log of N to the base M. This is defined to be the least int L such that M^L+1 > N. int log(int M,int N) { return log_aux(M,N,1); } int log_aux(int M,int N, int L) { int a = MyPower(M,L+1); if(a>N) return L; else log_aux(M,N,L+1); } ------------------------------------------- QUESTION : write fibonacci function . int MyFibonacci(int n) { if(n==1) || (n==2) return 1; else return MyFibonacci(n-1) + MyFibonacci(n-2); } ------------------------------------------- int Choose(int n,int k) { if( (k==0) || (k==N) ) return 1; else return choose(n-1,k) + choose(n-1,k-1); } choose(4,2)=? ------------------------------------------- QUESTION : What happens when the number of recursive calls made on any given level is under the control structure such as a for,while,do loop. This is called (trial and error) Backtracking. void y(int a,int b,int c); int main() { y(16,1,4); return 0; } void y(int a ,int b,int c) { int k; if(b<=c){ cout<