Recursion Flashcards

1
Q

Define Recursion:
(Think textbook version)

A

The process a procedure goes through, when one of the steps of the procedure involves rerunning the entire procedure!

(A call to self!)

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

Stack Stores…

A

Methods and local variables

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

Why is fibonacci sooo slow if we ask it to find fib() of a high number?

A

Redundant calls

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

Heap Stores…

A

Data structures (like arrays/arraylists!)

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

Fill in the blanks:
Recursion solves _____ problems by _____ them into _____ problems of the ______________.

A

LARGER
REDUCING
SMALLER
SAME FORM

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

5 steps recursive strat:

A
  1. Make sure you understand the LARGE problem
  2. Find SMALLER version of the problem (just by guessing)
  3. Confirm the guess is actually smaller
  4. Determine a terminating condition
  5. Code!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What must coders decide between when picking to use recursion?

A

High performance
vs.
Good software engineering

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

Pros of Recursion

A

Nice to look at
Some solutions are just naturally recursive
- less writing can lead to better understanding

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

Cons of Recursion

A

Takes up memory + CPU time!

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

T or F
some problems can ONLY be solved recursively; not through iterations.

A

False

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

T or F
problems that can be solved recursively can be solved through iterations.

A

True

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

T or F
A recursive method will never terminate unless it has a return statement.

A

False

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