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

How will you check the validity of an expression containing nested parentheses?

941


How to reverse a singly linked list?

1037


How many times is merge sort called?

898


What is bubble sort used for?

818


Why is selection sort used?

902


How does arraylist size work?

895


What is difference between list and linked list?

952


How many links are there in a binary tree of N nodes?

1022


How do we search a specific element in an array?

938


What is sequential search? What is the average number of comparisons in a sequential search?

807


What is an algorithm in coding?

875


What is homogeneous array?

869


Define binary tree insertion.

970


What is linear-logarithm chasm?

1025


What are the advantages and disadvantages of copyonwritearraylist?

1130