Algorithms and Data Structures · Junior · Question 26 of 75

What does every correct recursive function need?

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.

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 26

Test yourself

Take the Algorithms and Data Structures · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz