Ch3 Flashcards
1
Q
Recursive functions need two cases
A
Base case
Recursive case
2
Q
Base case
A
When to stop recursing
3
Q
Recursive case
A
When to keep recursing
4
Q
Push
A
Add a new item to the end
5
Q
Pop
A
Remove an item from the end
6
Q
Stack
A
A simple data with push and pop.
Like a stack of books. Last in first out.
7
Q
What to do if a call stack is too big
A
- Rewrite to use a loop
- Tail recursion
8
Q
Tail recursion
A
A recursive function where the recursive call is the last one executed. This can be optimized by the compiler in some languages to use less space on the call stack.