Knapsack Algorithm

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 9

Greedy Algorithm

Arunvinodh C

The Greedy Approach


Construct an optimum solution (output) piece by piece Generic Step: Having constructed some part of the optimum solution extend this by identifying the next part

Fractional Knapsack
N items
Each item has a profit Pi Size Si 1<=i<=n

A knapsack of capacity B

To find

Greedy approach
Pick items one by one Crucial Decision: how are you order these items?
Decreasing Profit? Increasing Sizes?

Exchange Trick

Exchange trick

What happens to the Profit?

Next Step
Prof of Knapsack Algorithm

You might also like