Algorithms and Data Structures · Junior · Question 26 of 75
What does every correct recursive function need?
- 1A global variable to store the result
- 2At least two recursive calls
- ✓Correct answer: A base case that stops the recursion
Explanation
Without a base case the function calls itself forever until the call stack overflows. Each recursive call must also move closer to the base case, for example with a smaller n.