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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / baskar

In recursive algorithm.
1. Base case gives the condition for recursive algorithm
when the recursive call is stop.
2.recursive case vice versa.

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More Data Structures Interview Questions

Write a Program for Linked list manipulation.

0 Answers  


which is the simplest file structure? (Sequential, indexed, random)

0 Answers  


How can I study data structures and algorithms?

0 Answers  


What is the need for path compression?

0 Answers  


Explain what is the bucket size, when the overlapping and collision occur at same time?

0 Answers  


In depth questions regarding the data structures and the Databases used in the Projects developed.

0 Answers   Motorola,


create an singly linked lists and reverse the lists by interchanging the links and not the data?

13 Answers   Microsoft, TCS,


Define an abstract data type (adt)?

0 Answers  


Define a stack?

0 Answers  


How does the bubble sort work?

0 Answers  


Is arraylist synchronized?

0 Answers  


What is structure of data type?

0 Answers  


Categories