1/11
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
What is recursion?
Recursion occurs when a method calls itself.
What are the two types of cases in a recursive method?
Base case and non-base case.
What is the purpose of a base case in recursion?
To terminate the recursion.
In the method 'go()', what does 'isClear(AHEAD)' represent?
It is the base case for the recursion.
What does the simple recursive algorithm for adding count look like?
If the thing you're counting still exists, return (adding amount) + recursive call(thing-1); otherwise, return base case.
What does the 'bunnyEars' method do?
It returns the total number of bunny ears based on the number of bunnies.
What is the return value of 'bunnyEars(3)'?
6 (because there are 3 bunnies, each with 2 ears).
What is the structure of a recursive method for matrix recursion?
Check if in bounds and some other condition, mark cell as visited, then make recursive calls for neighboring cells.
What does the 'play' method do?
It performs actions based on the conditions of the matrix and makes recursive calls.
What is the output of the method 'a(3,4)'?
15.
How does the method 'a(int n, int m)' work?
If n == 1, return m; otherwise, return m + a(n-1, m+1).
What is the result of '4 + a(2,5)' in the tracing of recursion?
11.