Recursion Flashcards
6 cards from real AP CSA practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Recursion flashcards as text
What is a recursive method that counts down from n printing each number called?
Answer: Linear recursion
A method making a single recursive call per invocation, working through a linear sequence, is called linear recursion.
What must be true about the argument in each recursive call to guarantee termination?
Answer: It must move closer to the base case
Each recursive call must use an argument that brings it closer to the base case, ensuring eventual termination.
How many total method calls does factorial(4) make (including the initial call)?
Answer: 5
factorial(4) calls factorial(3), which calls factorial(2), factorial(1), and factorial(0) — 5 calls total including the first.
Which of the following is NOT an advantage of recursion?
Answer: Always more memory-efficient than iteration
Recursion is not always more memory-efficient; each call uses stack space, so deep recursion can use more memory than iteration.
What is 'unwinding the stack' in recursion?
Answer: The process of returning from recursive calls back to the original caller
Stack unwinding is when recursive calls finish and return in reverse order, passing values back up to the original caller.
In AP CSA, which searching algorithm is commonly implemented recursively?
Answer: Binary search
Binary search is naturally implemented recursively by halving the search space with each call until the target is found or the range is empty.