Recursion is a different and powerful way of thinking about and solving problems. Recursion means “defining something in terms of itself” at some smaller scale, perhaps multiple times.
Many mathematical patterns can be described using recursion. Students may have seen recursive definitions of sequences. Recursive definitions often provide a clean and elegant expression of an infinite sequence or a complex structure. In a recursively defined sequence or pattern, each element is dependent on the elements that come before it.
In computer science, recursive algorithms can lead to conceptually simple programs. Recursion is typically used when a problem can be broken down into independent, smaller subproblems that are (1) solved through recursion and then (2) combined using the solutions generated by the smaller subproblems. To work correctly, recursive definitions as well as recursive algorithms need one or more base cases.
Recursion – Recursive Definitions
Recursion – Write a recursive or non-recursive function?