Recursive functions
To understand recursion, you must first understand recursion.
You may think of recursion as a programming structure where a function calls itself. We call such a function a recursive function. Many algorithms can be implemented using recursion. Here’s a brief introduction to recursion and recursive functions.
See also: Essential Algorithms, chapter 9 (Recursion, Basic Algorithms) for more on recursion, factorial, and Fibonacci.
Further reading
- (Stamford Encyclopedia of Philosophy)
- (Wikipedia)
- Hofstadter, Douglas R., Gödel, Escher, Bach : An Eternal Golden Braid. New York, Basic Books, 1979.
- See Chapter V. Recursive Structures and Processes. Note that this chapter also discusses stacks, pushing, and popping, which we’ll see a little later in the course.
Resources
Comprehension check
- Every recursive function must have at least one ___________ case and at least one ___________ case.
- Is recursion always the most efficient way to solve a problem?
- Without a __________________ recursion can lead to infinite regress.
Answers: ǝsɐɔ ǝsɐq / ou / ǝʌᴉsɹnɔǝɹ ’ǝsɐq
Amusement
Visit:
Copyright © 2023–2025 Clayton Cafiero
No generative AI was used in producing this material. This was written the old-fashioned way.