Recursive functions

Published

2023-08-05

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

Resources

Comprehension check

  1. Every recursive function must have at least one ___________ case and at least one ___________ case.
  2. Is recursion always the most efficient way to solve a problem?
  3. Without a __________________ recursion can lead to infinite regress.

Answers: ǝsɐɔ ǝsɐq / ou / ǝʌᴉsɹnɔǝɹ ’ǝsɐq

Amusement

Visit: https://thomaspark.co/2017/01/relevant-xkcd/

Gru’s plan, https://imgflip.com/memegenerator/Grus-Plan, with mods

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

No generative AI was used in producing this material. This was written the old-fashioned way.

All materials copyright © 2020–2023, The University of Vermont. All rights reserved.