Search the courses, subjects, tracks, games and features, or jump straight to a page.
5 cards from this section. Quick, good the night before a test.
What is the base case in a recursive function?
Think about what would happen if there were no stopping condition.
Provide an example of direct recursion.
Recall the definition of direct recursion.
What is the purpose of a base case in recursion?
Think about why we want to stop a function from calling itself forever.
Can recursion lead to stack overflow?
This can happen if the base case is not properly defined.
Create a recursive function that reverses a string. Provide the implementation.
Think about how you can break the string down.
Design a recursive function to find the greatest common divisor (GCD) of two numbers.
Use the properties of GCD to divide the problem.
7 more questions in this section. Enroll free to practise them all.
Enroll free