Dynamic Programming Flashcards

1
Q

What are the two main techniques used in Dynamic Programming?

A

Memoization (Top-Down), Tabulation (Bottom-Up).

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

What is the difference between top-down (memoization) and bottom-up (tabulation) DP?

A

Memoization uses recursion + caching, Tabulation uses loops.

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

What is the time complexity of solving Fibonacci with DP?

A

O(n).

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

How does the Knapsack problem use DP?

A

Optimize item selection within weight constraints.

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

What is the longest common subsequence (LCS) problem, and how is it solved?

A

Find the longest common sequence in two strings.

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

What is the difference between DP and Greedy algorithms?

A

DP finds global optimal, Greedy finds local optimal.

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