Surrounded by Boundaries
A bounded recursion is a type of recursive function in which the successive calls to itself have an end. It’s the most common type of recursive function, 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 finish 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 up to a parameterized number. For example, if we pass ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access