top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What do you mean by Base case, Recursive case, Binding Time, Run-Time Stack and Tail Recursion?

+4 votes
895 views
What do you mean by Base case, Recursive case, Binding Time, Run-Time Stack and Tail Recursion?
posted Aug 28, 2015 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

These terms are found in Recursion.

1.Base Case:

it is the case in recursion where the answer is known,or we can say the termination condition for a recursion to unwind back.

For example to find Factorial of num using recursion:

int Fact(int num){

if(num==1 || num==0)//base case
return 1;
else // recursive case: 
return num*Fact(num-1);
}

2.Recursive case:

It is the case which brings us to the closer answer.

Run Time Stack:

It is a system stack us to save the frame stack of a function every recursion or every call.This frame stack consists of the return address,local variables and return value if any.

Tail Recursion:

The case where the function consist of single recursive call and it is the last statement to be executed.A tail Recursion can be replace by iteration. The above funtion consists of tail recursion case.where as the below function does not.

void binary(int start,int end,int el){
int mid;
if(end>start){
mid=(start+end)/2;
if(el==ar[mid])
return mid;
else{
if(el>ar[mid])
binary(mid+1,end,ele);
else
binary(start,mid-11,ele);
}
}
}
answer Nov 20, 2015 by Manikandan J
Similar Questions
+5 votes

Please help me to understand the tail recursion with example.

+3 votes

What data structure would you mostly likely see in a non recursive implementation of a recursive algorithm?

...