answersLogoWhite

0

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);

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What are the differences between tail recursion and recursion, and how do they impact the efficiency and performance of algorithms?

Tail recursion is a special type of recursion where the recursive call is the last operation in the function. This allows for optimization by reusing the same stack frame for each recursive call, leading to better efficiency and performance. In contrast, regular recursion may require storing multiple stack frames, which can lead to higher memory usage and potentially slower execution.


When is it appropriate to use recursion?

In many problems the recursive solution is simple and elegant whereas the non-recursive solution is complex and difficult to code.In these cases the recursive solution can take advantage of the system stack for each function call, whereas in most non-recursive solutions, a stack in which to store data must be explicitly programmed


Can heap implement recursion?

Heap is a data-structure, it cannot implement anything. On the other hand, it is true that: 1. Recursive routines might use heap. 2. You can use dynamic memory allocation (heap), to implement a stack; and use the stack to implement recursion.


Which one is advantageous recrsion or iteration?

Depends... I teach algorithms and advice my students to choose whichever they find simpler to implement. Sometimes recursion is more intuitive than iteration and viceversa. All that is recursive can be done iterative and the other way around. The only problem you would have with recursion is having a stack overflow (if you call the recursive method too many times).


Is Recursion operation of the stack?

yes


Can you implement merge sort without using recursion?

Sure, recursion can always be substituted with using a stack.


How do you choose between recursion and iteration?

Some problems cry out for recursion. For example, an algorithm might be defined recursively (e.g. the Fibonacci function). When an algorithm is given with a recursive definition, the recursive implementation is straight-forward. However, it can be shown that all recursive implementations have an iterative functional equivalent, and vice versa. Systems requiring maximum processing speed, or requiring execution within very limited resources (for example, limited stack depth), are generally better implemented using iteration.


What is advantages of recursion in a data structure?

Recursive procedures are huge memory hogs. Also, they're a nightmare to debug. Finally, it's pretty rare to find an application that actually needs recursion as opposed to a simpler, more friendly methodolgy.


How do you overcome limitations of stacks in polygon filling?

You overcome limitations of the stack in polygon filling, or in any other algorithm, far that matter, but using an iterative technique, rather than a recursive technique. Recursion is quite useful, and can simplify algorithm design. Polygon filling, however, is a class of algorithm can potentially have a very deep recursion depth. This causes stress on the stack, hence the need for iteration.


What is the maximum depth of recursive calls a function may make?

Recursive function call depend your primary memory space because the recursive call store in stack and stack based on memory.


Why inlinefunctions can't be recursive?

Inline functions are just that, they are "inline", which means that the compiler injects the body of the function declaration into (inline to) the text segment without generating the actual call sequence. Without the call sequence, there is no stack frame, so there are no local variables. Without local variables or the stack frame, there can be no recursion.


What is the use of recursion function?

Read the part in your programming manual/text book about recursion. The short answer while easy does not tell you anything about the power or dangers of recursion. It is the power and dangers of recursion that is important because once understood you can use recursion to good effect without running out of stack space.