0
Any tips when I'm using recursion? Please 😢
2 Respostas
+ 4
Use it where it is appropriate. That is, use it when it feels natural. When you face a problem where it fits nicely, you will most likely recognize it: it will seem like you cannot even come up with a iterative solution. Also, clarity is an important aspect of programming. Others should be able to read and understand the code you produce. I think it is safe to say iterative loops are easier to understand at first sight than recursion.
0
Generally speaking just avoid it as long as you can. It's often slowest solution. Use it only when you have to, so for example when you wanna draw fractal.