Greedy Algorithms Flashcards

1
Q

What is a greedy algorithm?

A

Always makes the locally optimal choice.

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

What is an example of a problem that can be solved greedily?

A

Activity Selection, Huffman Coding.

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

Why does the activity selection problem use a greedy approach?

A

Pick earliest finishing activity first.

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

Why can’t greedy algorithms be used for all optimization problems?

A

Greedy doesn’t always find the global optimum.

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

What is the difference between Kruskal’s and Prim’s algorithm?

A

Prim’s builds a tree, Kruskal’s picks edges greedily.

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