A function that calls itself repeatedly, satisfying some condition, is called a Recursive Function.
We can't actually declare that recursive or non-recursive algorithms are good or bad. Some
problems inherently are better suited for recursion. Examples include Fibonacci series generation or
factorial of a number. Some advantages of recursive algorithms are:
• They are smaller in size (in terms of source code)
• They tend to be more elegant
Some disadvantages of recursion are:
•
Among other things, recursion requires more of stack than non-recursive algorithms (due to
several activation stacks for each call of the function)
• Coming-up with the correct algorithm requires a lot of careful thinking
• Testing recursive functions can be quite challenging
We can't actually declare that recursive or non-recursive algorithms are good or bad. Some
problems inherently are better suited for recursion. Examples include Fibonacci series generation or
factorial of a number. Some advantages of recursive algorithms are:
• They are smaller in size (in terms of source code)
• They tend to be more elegant
Some disadvantages of recursion are:
•
Among other things, recursion requires more of stack than non-recursive algorithms (due to
several activation stacks for each call of the function)
• Coming-up with the correct algorithm requires a lot of careful thinking
• Testing recursive functions can be quite challenging
Comments
Post a Comment
https://gengwg.blogspot.com/