Why recursion is required? How Recursive algorithm makes program effective? Write the merits and demerits of recursion in programming compare with iteration.


This answer is not selected as best answer. This answer may not be sufficient for exam.

Your limit has been exceed. We have implemented this system because, We got difficulty on managing our servers. Please donate some amount to remove this limit.

Quota: 0 / 30


Recursion is made for solving problems that can be broken down into smaller, repetitive problems. It is especially good for working on things that have many possible branches and are too complex for an iterative approach. One good example of this would be searching through a file system.

Recursion is required  because there are problems to solve which are recursive by nature. Non-recursive solutions to those problems are

  1. Complicated (because of the mismatch between the problem and the code) Fragile (be
  2. cause complicated)
  3. Harder to maintain and analyze (because of points 1 and 2)
  4. Potentially less efficient

Merits of recursion

  1. The code may be easier to write.
  2. To solve such problems which are naturally recursive such as tower of Hanoi.
  3. Reduce unnecessary calling of function.
  4. Extremely useful when applying the same solution.
  5. Recursion reduce the length of code.
  6. It is very useful in solving the data structure problem.
  7. Stacks evolutions and infix, prefix, postfix evaluations etc.

Demerits of recursion:

  1. Recursive functions are generally slower than non-recursive function.
  2. It may require a lot of memory space to hold intermediate results on the system stacks.
  3. Hard to analyze or understand the code.
  4. It is not more efficient in terms of space and time complexity.
  5. The computer may run out of memory if the recursive calls are not properly checked.
If you found any type of error on the answer then please mention on the comment or submit your new answer.
Leave your Answer:

Click here to submit your answer.

  Loading . . .