Greedy Algorithms Flashcards
1
Q
What is a greedy algorithm?
A
Always makes the locally optimal choice.
2
Q
What is an example of a problem that can be solved greedily?
A
Activity Selection, Huffman Coding.
3
Q
Why does the activity selection problem use a greedy approach?
A
Pick earliest finishing activity first.
4
Q
Why can’t greedy algorithms be used for all optimization problems?
A
Greedy doesn’t always find the global optimum.
5
Q
What is the difference between Kruskal’s and Prim’s algorithm?
A
Prim’s builds a tree, Kruskal’s picks edges greedily.