For the unbounded knapsack problem, let be the greatest total value obtainable with weight at most capacity . Assume positive integer item weights and nonnegative integer capacity . Set , and fill increasing capacities using
The zero alternative permits unused capacity. If a nonempty optimum includes item , removing one copy leaves a feasible smaller-capacity instance; its remaining value cannot exceed . Conversely every candidate in the displayed maximum is feasible, proving equality. The smaller-capacity state allows the same type again, implementing repetition.
The answer is , computed in time and space. Record an attaining item at each state to reconstruct the multiset. This is pseudopolynomial time, because is a number whose binary representation may have only bits. A positive-value zero-weight type would make the optimum unbounded and must be excluded or detected separately.

Articles by others on the same topic (0)

There are currently no matching articles.