Search This Blog

Thursday, April 28, 2016

RECURSION ADVANTAGES AND DISADVANTAGES

What are recursive functions? What are the advantages and disadvantages of Recursive algorithms?

A recursive function is a function which calls itself.
Advantages of recursive functions:
-Avoidance of unnecessary calling of functions.
-A substitute for iteration where the iterative solution is very complex. For example to reduce the code size for Tower of Honai application, a recursive function is best suited.
- Extremely useful when applying the same solution

Disadvantages of recursive functions :
-A recursive function is often confusing.
-The exit point must be explicitly coded.

-It is difficult to trace the logic of the function.

No comments:

Post a Comment