+ 1
Recursion
What disadvantages are in using recursion?
11 Respuestas
+ 3
There is solution for problems with stack memory in Python. From functools import lru-cache and from sys import setrecursionlimit.
+ 3
If you mess up the base case, you get infinite recursion and a stack overflow.
+ 2
What about it's understanding, you're right)
+ 2
Thank you for answer) Recursion is the one thing that was making me problems during my learning.
+ 1
Reduce wastage of time for writing the code
+ 1
From my experience as ~ swim ~ said it can be difficult to understand especially if not written properly also the maximum recursion depth (1000 in python by default) is reached very quickly. But there are problems that have a recursive nature embedded in their cores that they can only be solved using recursion or otherwise are very very difficult to impliment using loops. For exemple solving a Hanoi tower in recursion is suprisingly easy compared to loops (and i don't even know if it can be done that way). So, i recommend using loops if possible and use recursion when the solution necessits it.
+ 1
I tried to find the solution of Tower by using loops, and also didn't find it. Usually I use recursion if there's really necessary.
+ 1
The major disadvantage is complexity of program..and the stack size
0
Don't forget about the base case - is just very important rule, not disadvantage, I think.. It's like a situation in infinite loops.