Heuristics and Dynamic Programming (DP) Flashcards

1
Q

What are the four different paradigms for finding solutions to problems?

A

Brute Force
Divide-and-Conquer
Heuristics
Dynamic Programming

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

What is Brute Force?

A

Generate and test all possibilities
Useful in small cases, but gets very quickly out of hand for larger cases

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

What is Divide-And-Conquer?

A

Break the problem into smaller pieces, solve them, and then put them back together e.g. Merge Sort

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

What is a heuristic?

A

Generally, meant to mean something that gives better decisions, than the naive methods, but still not necessarily optimal
Two types:
Decisions within a procedure that give exact/optimal answers, but are designed to make it go faster
Decisions within a procedure that might not give optimal answers, but are designed to give good answers that are impractical to obtain otherwise

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

What are heuristics in exact methods?

A

General methods that work in an algorithm that does give exact or optimal answers, but need the heuristic to decrease the average/typical runtime

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

What are heuristics in inexact methods?

A

Generally methods that are not guaranteed to give the best possible answers, but that can give good answers quickly
Used on problems when the exact methods are too slow

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

What is a greedy algorithm?

A

Take the decision that looks best in the short term, without looking ahead

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

How does the greedy algorithm work on the change-giving problem?

A

Iterate the process of picking the largest coin which is still available and does not cause the set to exceed the target

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

What is dynamic programming?

A

Solve small sub-problems first, then build up towards the full solution

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

How does DP work for Subset Sum?

A

Consider the numbers one at a time, keeping track of ‘which subset sums are possible so far’

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

What is the complexity of DP?

A

Outer loop - O(n)
Inner loop - O(k)
Overall - O(n K) (also written as O(n 2^B)

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