A Common-Sense Guide to Data Structures and Algorithms, Second Edition, 2nd Edition
by Jay Wengrow
Recursive Category: Calculations
In the previous section, we discussed the first category of recursive functions—those whose job it is to repeatedly execute a task. For the remainder of this chapter, I’ll elaborate on a second general category: performing a calculation based on a subproblem.
There are many functions whose goal it is to perform a calculation. A function that returns the sum of two numbers, or a function that finds the greatest value within an array, are examples of these. These functions receive some sort of input, and return the result of calculations involving that input.
In Chapter 10, Recursively Recurse with Recursion, we found that one area in which recursion shines is where we need to act on a problem that has an arbitrary ...
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