10.3. Recursion Summary

In this unit you learned about recursion. A recursive method calls itself (contains a call to the method from inside of the method). A recursive method should have at least one way to stop the recursion. This is called a base case.

10.3.1. Concept Summary

  • base case - A way to stop the recursive calls. This is a return without a recursive call.

  • call stack - The call stack keeps track of the methods that are called while the code executes. It keeps track of the local variables and where the call will return to.

  • recursive method - A method that contains at least one call to itself inside the method.

10.3.2. Vocabulary Practice

Before you keep reading...

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

10.3.3. Common Mistakes

  • Missing the recursive call. Be sure to 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 all of it.

You have attempted 1 of 2 activities on this page