I graduated in 1990 in Electrical Engineering and since then I have been in university, doing research in the field of DSP. To me programming is more a tool than a job.
Both examples shown have the advantage of simplicity, but they could be also easily implemented in an iterative way. This could give the impression that recursion is just a fancy way to do something.
I think it would be nice to have also an example of "pure recursion," that is a problem that is easily solved with recursion, but not so easily in an iterative way. The only examples that come to my mind right now are the Hanoi tower and recursive figures like the Sierpiński triangle (the latter can be implemented iteratively using an expansion in base N, but it is not as immediate as the recursive solution).
Thanks for the comment, Ricardo. As someone who is relatively new to concepts such as recursion, I wanted to explain it in a simple way that would make sense to beginners, as that was the type of material I was looking for when I first started out. Providing more complex examples could be something that I examine in the future.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Both examples shown have the advantage of simplicity, but they could be also easily implemented in an iterative way. This could give the impression that recursion is just a fancy way to do something.
I think it would be nice to have also an example of "pure recursion," that is a problem that is easily solved with recursion, but not so easily in an iterative way. The only examples that come to my mind right now are the Hanoi tower and recursive figures like the Sierpiński triangle (the latter can be implemented iteratively using an expansion in base N, but it is not as immediate as the recursive solution).
Thanks for the comment, Ricardo. As someone who is relatively new to concepts such as recursion, I wanted to explain it in a simple way that would make sense to beginners, as that was the type of material I was looking for when I first started out. Providing more complex examples could be something that I examine in the future.