Professional Documents
Culture Documents
20IS42 Module 3
20IS42 Module 3
(20IS42)
Module 3
• By,
MANJESH R,
Assistant Professor,
IS&E, VVCE, Mysuru - 02
Greedy Method: Introduction
• Its is the one of the approach to solve the problems.
• The problems which requires minimum or maximum results are
called as Optimization problems.
• A problem can have many solutions and only some solutions can
satisfy the given constraint, then they are called Feasible solution.
• If there is a cost involved with the problem should be minimum
then, this is called Minimization problem.
• For a given problem we may get different solution called feasible,
among these one solution will give best result/profit that is called
Optimal solution.
• Two types of solution : feasible solution & optimal solution.
• Feasible solutions can be many but optimal solution will be only
one.
• Solution found in each step of the algorithm cannot be changed
on subsequent steps, it is called as irrevocable.
Dept. of ISE, VVCE, Mysuru - 02
Greedy method works as follows
• At each stage, a decision is made regarding whether selection of a
particular input leads to an optimal solution.
• If the inclusion of next input will result in an infeasible solution,
then it is not added .
• A decision made in one stage is not changed in a later stages. So,
each decision should be valid first.
• Prim’s algorithm
• Kruskal’s algorithm
• Dijkstra’s algorithm
• Huffman Trees and Codes
• Knapsack problem
• Job sequencing with deadlines
Stage 2:
Stage 4:
Stage 5: