1. Greedy Algorithm (0-1 Knapsack Problem)
Presented by :
Muskaan
Swati Rani
Presented to :
Ms. Pooja Jha
2. Introduction
Greedy is an algorithmic paradigm that builds
up a solution piece by piece, always choosing
the next piece that offers the most obvious
and immediate benefit.
So the problems where choosing locally
optimal also leads to global solution are best
fit for Greedy.
3. A Greedy algorithm works if a problem
exhibits the following two properties :
1. Greedy Choice Property
2. Optimal Substructure
4. Areas of Application
Greedy approach is used to solve many
problems , such as
Finding the shortest path between two
vertices using Dijkstra’s algorithm
Finding the minimal spanning tree in a
graph using Prim’s / Kruskal’s algorithm etc.
Finding the maximum profit for the items to be
filled in a fixed weighted bag from Knapsack
algorithm
5. In general , Greedy algorithms have five
components :
1. A candidate set
2. A selection function
3. A feasibility function
4. An objective function
5. A solution function
6. Pros
Finding solution is quite easy with Greedy
algorithm for a problem
Analyzing the run time for Greedy algorithms
will generally be much easier than for other
techniques(like Divide and conquer)
Cons
It is not suitable for problems where a solution
is required for every sub problem like sorting
In such problems, the Greedy strategy can be
wrong ; in worst case even lead to a non-
optimal solution
7. 0-1 Knapsack Problem
The problem is called a “0-1” problem,
because each item must be entirely accepted
or rejected
Example : finding the least wasteful way to
cut raw materials, selection of investments
and portfolios.