Problem Statement:
Find the maximum value for the given capacity of Knapsack.
Input vectors are :
Values (v) | 15 | 9 | 5 | 10 |
Weights (w) | 1 | 3 | 4 | 5 |
Solution:
This problem involves filling the knapsack with objects with maximum value.
Inputs to the problem are Values , Weights of the objects and the knapsack capacity.
You have to pick up the objects from the given set such that total weight of the objects is utmost the capacity of knapsack.
Optimal Sub-Structure Equation:
V(i,W) = V(i -1 , W ) , If wi > W
= V(i – 1 , W) , not choosing the ith term
= vi + V(i -1 , W – wi) , choosing the ith term
Read full article from Coding Recipies: Knapsack Problem
No comments:
Post a Comment