Discussing the article: "From Basic to Intermediate: Recursion"

 

Check out the new article: From Basic to Intermediate: Recursion.

In this article we will look at a very interesting and quite challenging programming concept, although it should be treated with great caution, as its misuse or misunderstanding can turn relatively simple programs into something unnecessarily complex. But when used correctly and adapted perfectly to equally suitable situations, recursion becomes an excellent ally in solving problems that would otherwise be much more laborious and time-consuming. The materials presented here are intended for educational purposes only. Under no circumstances should the application be viewed for any purpose other than to learn and master the concepts presented.

Typically, loops are created in one of two ways: by using dedicated loop control structures or by using functions or procedures. Yes, dear reader, it may sound strange to use a function or procedure to create a loop. Yet it's far more common than you might think.

When we use loop constructs to create repetitions, we refer to this as iterative programming. When we use functions or procedures for the same purpose, it's known as recursive programming. Understanding how to create and apply recursion is something every beginner should learn - recursive loops are, in many cases, easier to understand.

So why am I only bringing this up now? Because using recursion effectively in your code requires a solid understanding of a few key concepts: the 'if' statement, the proper use of variables and constants, understanding lifespan and value transfer, and - most importantly - a strong understanding of data types and their limitations. Depending on what you're doing, selecting the most appropriate type is important.


Author: CODE X

 

Recursion === Stack Overflow.

Great closing paragraph.  I have been using recursion for 55 years and find generally iterative loops are better and simpler to understand.  Recursion works well when  number of levels cannot be predetermined.