Ch3 Flashcards

1
Q

Recursive functions need two cases

A

Base case
Recursive case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Base case

A

When to stop recursing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Recursive case

A

When to keep recursing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Push

A

Add a new item to the end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Pop

A

Remove an item from the end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Stack

A

A simple data with push and pop.

Like a stack of books. Last in first out.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What to do if a call stack is too big

A
  1. Rewrite to use a loop
  2. Tail recursion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly