Practical uses for Recursion -
are there times better use recursion task instead of other methods? recursion referring to:
int factorial(int value) { if (value == 0) { return 1; } else { return value * factorial(value - 1); } }
well, there few reasons can think of.
recursion easier understand purely iterative solution. example, in case of recursive-descent parsers.
in compilers support tail call optimization, there's no additional overhead using recursion on iteration, , results in fewer lines of code (and, result, fewer bugs).
Comments
Post a Comment