Professional Documents
Culture Documents
Slide - 4 - Greedy
Slide - 4 - Greedy
Introduction
Algorithms for optimization problems typically go through a sequence
of steps, with a set of choices at each step.
For many optimization problems, using dynamic programming to
determine the best choices is overkill;
Simpler, more efficient algorithms will do.
Greedy Algorithms : Definition
A greedy algorithm always makes the choice that looks best at the
moment.
That is, it makes a locally optimal choice in the hope that this choice
will lead to a globally optimal solution.
Does it provide optimal solution?
Not always!
But for some cases, it does.
0-1 Knapsack Problem : DP
Item Name Price Weight Ratio
No.
1. Algorithm Book 840 7 120
(Original copy)
2. A Ornament box 2250 15 150
20
3. Fish 420 6 70
20
An activity-selection problem