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 |
Q # 1 : in which graph algorithm do we start finding vertices that should be first in the topological order and then apploy the fact that every vertex must come before its successors in the topolgical order.
List out the disadvantages of using a linked list?
What is bubble sort used for?
Tell me what should be done in the base case for this recursive problem?
Define tree edge?
Write an algorithm to find middle element in the linked list.
What is the impact of signed numbers on the memory?
What is a Queue? Explain its operation with example?
Q#1: An algorithm is made up of 2 modules M1 and M2.If order of M1 is F(n) and order of M2 is g (n) then what is the order of the algorithm. Q # 2 : How many binary trees are possible with 3 nodes? with 4 nodes?
Is it possible to make an array volatile in java?
What is red black tree in data structure?
Sorting is not possible by using which of the following methods? (a) Insertion (b) Selection (c) Exchange (d) Deletion