Data Structures
How does a recursive function know when to stop?
A recursive function must always include a test to determine if another recursive call should be made, or if the recursion should stop with this call.
What is a recursive function/algorithm?
A solution that is expressed in terms of (a) smaller instances of itself and (b) the base case.
What are the benefits and disadvantages to iteration?
Benefit - executes more efficiently. Disadvantage - harder to code or understand.
What are the benefits and disadvantages to recursion?
Benefit - solves problems in a simple and elegant way. Disadvantage - may not execute efficiently.
What are the types of recursion?
Direct - A function calls itself. Indirect - function A calls function B, and function B calls function A,.....
What is a run-time stack?
Each time a function is called, the computer system creates temporary storage for the parameters and the function's local variables.
What does recursive mean?
Having the characteristic of coming up again, or repeating.
What is the base case of a recursive function?
The case for which the solution can be stated non-recursively.
What is the general case for a recursive function?
The case for which the solution is expressed in terms of a smaller version of itself; also known as recursive case.
What is a "general case" in a recursive program?
The smallest version possible.
What are recursive functions used for?
To reduce a complex problem into a simpler-to-solve problem (base case).
What happens if there are no base cases?
You have an infinite recursion, the recursive equivalent of an infinite loop.