Bounded Recursion

Understand what bounded recursive functions are and how to create them.

Introduction to bounded recursion

A bounded recursion is a recursive function in which the successive calls to itself have an end. It’s the most common type of recursive function and is present in all list-navigation code. Every time a recursive function calls itself, that’s an iteration. Every time a bounded recursion iterates, it requires fewer iterations to finish. We’re diminishing the steps to complete the program execution in each iteration, even if we can’t easily predict the total number of iterations.

The number of repetitions of a bounded recursive function is directly associated with the arguments that it receives. We can see how it works by creating a program that sums all integers from 0 to a parameterized number. For example, if we pass the number 3, the program will generate the sum 3+2+1+0. It must ...