Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

ple.. briefly describe the purpose of having a base case and
a recursive case in a recursive algorithm

Answer Posted / arka

Lets assume factorial function defined recursively:
int fact(int n)
{
if(n==0||n==1)
return(1); //base case
else
return(n*fact(n-1)); //recursive case
}
the necessity for recursive case is simply recursion
whereas the base case is needed to terminate the recursion.
eg:fact(4)=>4*fact(3)=>4*3*fact(2)=>4*3*2*fact(1)=4*3*2*1.
for fact(1) hte base case is satisfied and the function
fact is not called again.

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define quadratic probing?

989


Where the data structures are used?

923


What is the best data structure and algorithm to implement cache?

930


How do you do binary search?

839


Define static data structures?

947


Is bucket sort a comparison sort?

800


What is difference between list and array?

857


Can tuple be sorted?

883


Write an algorithm to show the reverse of link list?

825


Is hashset a collection?

874


Which interfaces are implemented by linkedlist?

905


what is the difference between singly and doubly linked lists?

934


What do you understand by stable sort?

849


What is frozenset?

853


What is a string or array type?

778