algorithm - Knapsack with unbounded items -


i familiar 0-1 knapsack problem , when given number of copies each item can figure out how solve when given infinite copies of each item using dynamic programming. trying solve hand right not interested in particular code. example here how solve 0-1 problem. how need modify if given infinity amount of copies of each item?

edit: aware there second solution problem containing items 1,2, , 3 same total value.

one possibility provide suitable number of multiplicities of items. item i, there can @ most

m_i := k / w_i 

choices of item, k denotes knapsack capacity , w_i denotes weight of i-th item. furthermore, each weight value occurs in instance, there @ 1 item type necessary, namely 1 maximum profit respect weight.

equivalently, 1 modify evaluation of dynamic program reflect different number of items taken, instead of distinguishing between choice of 0 , 1.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

php - Find a regex to take part of Email -

javascript - Function overwritting -