DP Flashcards

1
Q

Does DP explore all possible solutions?

A

Yes

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

What are characteristics of DP problems?

A

1) The problem can be broken down into “overlapping subproblems”
2) The problem as “optimal substructure”

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

What is an overlapping subproblem?

A

Smaller versions of the original problem whose answer can be reused

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

What is optimal substructure?

A

An optimal solution can be found by combining the optimal results from the overlapping subproblems of the original problem.

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

Is divide and conquer DP?

A

No because the subproblems are not overlapping.

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

What does memoizing a result mean?

A

Store the result of a function call, usually in a hash map, so that we can quickly return the cached results instead of recalculating.

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

Advantage of bottom-up DP?

A

implementation is usually faster as iteration if faster than recursion

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

Advantage of top-down DP?

A

Usually easier to write as we don’t need to consider the order of the subproblems.

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

What is tabulation?

A

bottom-up DP

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

What is memoization

A

top-down DP

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

In general how do we know to use a DP algorithm?

A

If the problem is asking for a min/max/number and if future decisions are effected by past decisions, use DP. Otherwise it is probably greedy.

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

In general how do we know to use a DP algorithm?

A

If the problem is asking for a min/max/number, then likely DP or greedy. Then if future decisions are effected by past decisions, use DP. Otherwise it is probably greedy.

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