What are advantages and disadvantages of recursive
calling ?

Answers were Sorted based on User's Feedback



What are advantages and disadvantages of recursive calling ?..

Answer / santhi

advantage:using recursion we can avoid unnecessary calling
of functions.
disadvantage:by too many recursive functions there may be
confusion in the code.

Is This Answer Correct ?    134 Yes 53 No

What are advantages and disadvantages of recursive calling ?..

Answer / sachin mahajan

Advantages:
Through Recursion one can Solve problems in easy way while
its iterative solution is very big and complex.
Ex : tower of Hanoi
You reduce size of the code when you use recursive call.

Disadvantages :
Recursive solution is always logical and it is very
difficult to trace.(debug and understand)

Before each recursive calls current values of the varibles
in the function is stored in the PCB, ie process control
block and this PCB is pushed in the OS Stack.
So sometimes alot of free memory is require for recursive
solutions.

Remember : whatever could be done through recursion could be
done through iterative way but reverse is not true.

Is This Answer Correct ?    103 Yes 30 No

What are advantages and disadvantages of recursive calling ?..

Answer / anonymous

Advantage :

Recursion is used to divide the problem into same problem
of subtypes and hence replaces complex nesting code.

Disadvantage :

Recursion takes a lot of stack space, usually not
considerable when the program is small and running on a PC.

It is very hard to debug or extend the functionality in
case of recursive logic.

Is This Answer Correct ?    66 Yes 8 No

What are advantages and disadvantages of recursive calling ?..

Answer / rahul

advantage:using recursion we can avoid unnecessary callingof
functions.
disadvantage:recursive calling increase the space complexity.

Is This Answer Correct ?    45 Yes 15 No

What are advantages and disadvantages of recursive calling ?..

Answer / morfy

Use of recursion in an algorithm has both advantages and
disadvantages. The main advantage is usually simplicity.
The main disadvantage is often that the algorithm may
require large amounts of memory if the depth of the
recursion is very large. High memory consumption is due to
large function call number (recursion means that function
calls itself multiple times).

Is This Answer Correct ?    26 Yes 5 No

What are advantages and disadvantages of recursive calling ?..

Answer / ganesh narayanan

advantage : A recursive definition defines an object in simpler cases of itself reducing nested looping complexity

disadvantage : less efficient as compared to the non-recursive counterparts as the overhead involved in entering,re-entering and exiting a block is avoided in case of the non recursive forms. its also possible to identify a number of local variables which need not be saved and restored with the help of stacks and this unwanted stacking activity is avoided in the non-recursive versions.

Is This Answer Correct ?    26 Yes 7 No

What are advantages and disadvantages of recursive calling ?..

Answer / sk_seeker

Why is recursion frowned upon??

User space programs: memory consumption
----------------------------------------
User stack is a dynamic stack i.e. we page fault on the
stack virtual addresses and resolve the fault by allocating
a physical page. Many recursions can lead to a lot of (user
stack) memory being consumed. In a traditional programming
model, when a thread blocks, then all the memory is stuck
with the thread, until the paging daemon kicks it out. So,
effectively, many threads doing recursive calls can consume
a lot of memory and force memory pressure to occur in the
system i.e. system slows down.

Kernel Space program: stack depth
---------------------------------
A kernel stack is fixed in size i.e. 8K or 16K usually. And
this stack does not grow dynamically in most OSes. So,
there is a bound on how much memory can be used for the
kernel stack, unlike user programs. But, this bound on the
stack size is the reason why recursion is discouraged. More
recursive levels can lead to a stack overflow and this will
panic the box. One might say: hey, my recursive depth is
only 10. But, what is unknown is what amount of kernel
stack is already used up && the stack frame consumption
depends on the chip architecture that is being used.

For both of the above reasons, recursion is avoided in
general kernel programming.

Is This Answer Correct ?    20 Yes 12 No

What are advantages and disadvantages of recursive calling ?..

Answer / nishu

disadvantage:
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.

Is This Answer Correct ?    6 Yes 1 No

What are advantages and disadvantages of recursive calling ?..

Answer / gadadhar dutta

Disadvantage of recursion
1. It is requires extra storage space. The recursive calls and automatic variable a stored on the stack. For every calls separate memory is allocated to automatic variable with the same name.
2. the recursion function is not efficient in execution speed and time.
3. Some function called inside recursion are repeated or duplicated just like Fibonacci.

Is This Answer Correct ?    2 Yes 0 No

What are advantages and disadvantages of recursive calling ?..

Answer / swapna

advantages ;
recursive functions can be effectively used to solve
problems where the solution is expressed in terms of
applying the same solution.
disadvantages ;
in recursive we must have an if statement somewhere to
force the func. to return without the recursive call being
executed.otherwise the funct. will never return.

Is This Answer Correct ?    22 Yes 36 No

Post New Answer

More C Interview Questions

If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

0 Answers  


What is a structure and why it is used?

0 Answers   Hexaware,


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

0 Answers  


What do you understand by friend-functions? How are they used?

0 Answers   iNautix,


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

0 Answers  






how to find binary of number?

2 Answers  


while initialization of two dimensional arrays we can initialize like a[][2] but why not a[2][] is there any reason behind this?

4 Answers   Aptech,


What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }

2 Answers  


What is an array in c?

0 Answers  


write a program to find a given no. is divisible by 3 or not without using any arthimetic operators?

3 Answers   Broadcom, TCS,


What is the scope of global variable in c?

0 Answers  


What is main () in c?

0 Answers  


Categories