Greedy Method Session 8
Greedy Method Session 8
• Introduction
• Optimization Problem – Definition
• The Greedy Method
• Pseudo-code for Greedy Algorithm
• Example: Coin Changing Problem
• A Greedy Solution for Coin Changing Problem
Introduction:
- A greedy algorithm is any algorithm that follows the problem-solving heuristic of making the locally
optimal choice at each stage.
- In many problems,
o a greedy strategy does not usually produce an optimal solution,
o but nonetheless a greedy heuristic may yield locally optimal solutions that approximate a
globally optimal solution in a reasonable amount of time.
Optimization Problem – Definition
An Optimization Problem:
• Given a problem instance, a set of constraints and an objective function.
• Find a feasible solution for the given instance for which the objective function has an optimal
value
• either maximum or minimum depending on the problem being solved.
• A feasible solution satisfies the problem’s constraints
• The constraints specify the limitations on the required solutions.
• For example:
the knapsack problem
the Coin-Change problem