Any tips when I'm using recursion? Please 😢 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Any tips when I'm using recursion? Please 😢

19th Nov 2016, 10:05 AM
Bijoy
2 Answers
+ 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.
19th Nov 2016, 12:48 PM
Remmae
Remmae - avatar
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.
19th Nov 2016, 11:26 AM
Jakub Stasiak
Jakub Stasiak - avatar