answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: Is it necessary to have a base case in all recursive algorithms?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is base case?

A base case is the part of a recursive definition or algorithm which is not defined in terms of itself.


What is a base case?

A base case is the part of a recursive definition or algorithm which is not defined in terms of itself.


What is a recursive formula and what is it used for Geometric and Arithmetic?

A recursive definition is any definition that uses the thing to be defined as part of the definition. A recursive formula, or function, is a related formula or function. A recursive function uses the function itself in the definition. For example: The factorial function, written n!, is defined as the product of all the numbers, from 1 to the number (in this case "n"). For example, the factorial of 4, written 4!, is equal to 1 x 2 x 3 x 4. This can also be defined as follows: 0! = 1 For any "n" > 0, n! = n x (n-1)! For example, according to this definition, the factorial of 4 is the same as 4 times the factorial of 3. Try it out - apply the recursive formula, until you get to the base case. Note that a base case is necessary; otherwise, the recursion would never end.


Why recursive algorithms are difficult to implement in programming language?

Recursive algorithms work in an opposite direction as compared to normal algorithms or loops. First the recursion occurs then it back tracks, both of these steps combine to give what a loop does in one single step. But values may change in both the steps, thus complicating the algorithm. For eg: int fact(int n) for(i=1;i<=3;i++) { { if(n!=1) fact=fact*i; return(n*(n-1)); } else return fact; return 1; } Here suppose you take n as 3, then first n decreases to 1 after that for each value returned, it multiplies with the previous returned value. Hence giving the answer 6. But in case of for loop it works linearly...


What are recursive locks?

Recursive locks (also called recursive thread mutex) are those that allow a thread to recursively acquire the same lock that it is holding. Note that this behavior is different from a normal lock. In the normal case if a thread that is already holding a normal lock attempts to acquire the same lock again, then it will deadlock. Recursive locks behave exactly like normal locks when another thread tries to acquire a lock that is already being held. Note that the recursive lock is said to be released if and only if the number of times it has been acquired match the number of times it has been released by the owner thread. Many operating systems do not provide these recursive locks natively. Hence, it is necessary to emulate the behavior using primitive features like mutexes (locks) and condition variables.


Which algorithm has some average worst case and best case time?

All algorithms have a best, worst and average case. Algorithms that always perform in constant time have a best, worst and average of O(1).


What do you mean by base case recursive case binding time runtime stack and tail recursion?

These terms are found in Recursion.1.Base Case:it is the case in recursion where the answer is known,or we can say the termination condition for a recursion to unwind back.For example to find Factorial of num using recursion: int Fact(int num){ if(num==1 num==0)//base casereturn 1;else // recursive case: return num*Fact(num-1);} 2.Recursive case:It is the case whcih brings us to the closer answer. Run Time Stack:It is a system stack us to save the frame stack of a function every recursion or every call.This frame stack consists of the return address,local variables and return value if any. Tail Recursion:The case where the function consist of single recursive call and it is the last statement to be executed.A tail Recursion can be replace by iteration. The above function consists of tail recursion case.where as the below function does not. void binary(int start,int end,int el){int mid;if(end>start){mid=(start+end)/2;if(el==ar[mid])return mid;else{if(el>ar[mid])binary(mid+1,end,ele);elsebinary(start,mid-11,ele);


What is the two properties of recursive procedure?

The two properties of a recursive object or routine, F, are:F must have a simple base case (or have simple base cases).F must have a set of rules that reduces all other cases towards the base case.A classic example of recursion is the definition of a factorial.Fact(0) = 1Fact(n) = n * Fact(n - 1)For computer science, writing this function in JavaScript would look like:function factorial(n) {if (n === 0) {return 1;} else {return n * factorial(n - 1);}}


What is simulation recursion in C?

The factorial f(n) = n * (n-1) * (n-2) * .. 1. For example factorial 5 (written as 5!) = 5 x 4 x 3 x 2 x 1 = 120. The function below returns the factorial of the parameter n. int factorial( int n) { if (n==1) return 1 else return n* factorial( n-1) ; }


Is there a Powerball numbers picker with no download that accually works?

It would most certainly be nice to find such a program. However, in order for an application like that to work, it would first have to have access to the Powerball machine's algorithms. Then, it would be necessary to accurately predict the outcome of each random drawing. This would have a slim margin for accuracy even with the algorithms. As this is the case, there has yet to be such a program that works as advertised.


Case complexity in data structure algorithms?

The complexity of an algorithm is the function which gives the running time and/or space in terms of the input size.


Is it necessary to buy a leather laptop case?

"A leather laptop case isn't necessary, but depending on if you need it then it may be necessary. Most people don't need a leather laptop case. A variety of laptop cases are available on the market."