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
i want to know the procedure of qualcomm for getting a job through offcampus
What is variable and explain rules to declare variable in c?
How can I dynamically allocate arrays?
What is the most efficient way to store flag values?
Define Spanning-Tree Protocol (STP)
What is the purpose of & in scanf?
What is structure and union in c?
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
write a c program to find the sum of five entered numbers using an array named number
What is scanf () in c?
Was 2000 a leap year?
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
What is #ifdef ? What is its application?
When should you use a type cast?
What is an auto keyword in c?