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
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 |
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 |
Is hashmap part of collection?
What is the use of tree data structure?
In an avl tree, at explain what condition the balancing is to be done?
Tell me the difference between structure and array?
What things you would care about to improve the performance of application if its identified that its db communication that needs to be improved?
What is binary tree give example?
What are scalar values?
How would you check if a binary tree is BST or not ? Write a program.
Explain about set and their types in a collection?
What is top in stack?
What is circular queue in data structure?
Which sorting is worst?