what are the advantage and disadvantage of recursion
Answer Posted / vasu jain
Recursion
Advantage
i. Usually simplicity.
ii. Although at most of the times a problem can be solved without recursion, but in some situations in programming, it is a must to use recursion. For example, a program to display a list of all files of the system cannot be solved without recursion.
iii. The recursion is very flexible in data structure like stacks, queues, linked list and quick sort.
iv. Using recursion, the length of the program can be reduced.
Disadvantage
i. It requires extra storage space. The recursive calls and automatic variables are stored on the stack. For every recursive calls separate memory is allocated to automatic variables with the same name.
ii. Often the algorithm may require large amounts of memory if the depth of the recursion is very large. If the programmer forgets to specify the exit condition in the recursive function, the program will execute out of memory.
iii. The recursion function is not efficient in execution speed and time.
iv. Some function calls inside recursion are repeated or duplicated just like fibonacci
| Is This Answer Correct ? | 47 Yes | 5 No |
Post New Answer View All Answers
How do c compilers work?
What are the basic data types associated with c?
Are negative numbers true in c?
When should I declare a function?
Write a program to print numbers from 1 to 100 without using loop in c?
What is sizeof return in c?
In C programming, what command or code can be used to determine if a number of odd or even?
What is malloc() function?
What is the difference between c &c++?
Where are some collections of useful code fragments and examples?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
Is there a built-in function in C that can be used for sorting data?
write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3
Explain which function in c can be used to append a string to another string?
How to define structures? ·