Recursion Summary
Introduction: 10.3.0
- We learned about recursion
- A recursive method calls itself
- It should have at least one way to stop this recursion
- This is a base case
- It should have at least one way to stop this recursion
- A recursive method calls itself
Concept Summary: 10.3.1
base case
- A way to stop recursive calls
- This returns a value instead of a recursive call
Call stack
- The call stack keeps track of methods as they are called
- It keeps track of local variables and where the call will return to
- Calls can only be added to and popped off the top of the stack
recursive method
- A method that contains at least one call to itself inside the method
Common Mistakes: 10.3.3
- Missing the recursive call
- Look for a call to the same method!
- Getting confused about when a recursive method returns and what it returns
- Assuming you understand what the recursion is doing without tracing the entire method call
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
This was adapted from the CS Awesome curriculum, which was created by
Barbara Ericson, Beryl Hoffman, and many other CS Awesome contributors. All rights reserved.
CS Awesome is licensed under CC BY-NC-SA 4.0.