Recursion
Overview
This lesson introduces the wonders of recursion.
There are two components to this lesson:
- myGA module: Recursion
- If the above link does not take you to the correct module, you can find the lesson in your myGA dashboard.
- In-Class Exercise: Writing Recursive Functions
Note: The myGA module contains a link to an exercise in CodePen. The code in CodePen is the exact same as the code for the in-class exercises. Try out the exercise in CodePen and see how far you can get with it. Leave off where you get stuck and we'll review the solution in class.
Learning Objectives
By the end of this lesson, you will be able to:
- Define recursion.
- Write the base case and recursive cases of a recursive function.
- Identify functions that use recursion and explain why it’s used.
Duration
1.5 hours total:
- 0.5 hour myGA
- 1 hour in class
Prerequisites
- Big O Notation
Additional Resources
- How recursion comes up in job interviews.
- More thoughts on recursion in job interviews.
- Sketching out a recursive function.
- Just for fun: The recursion subreddit.