


In this approach, every set of items are tried, and for every set, the value is calculated. Using Exhaustive SearchĮxhaustive search means applying the brute force approach. The knapsack problem can be solved either by using the exhaustive search or using dynamic programming. Since it is a 0 - 1 knapsack problem hence, splitting the item is not allowed, i.e., one can never break any given item, either do not pick it or pick it (0 - 1 property). Also, the sum of weights of all the items present in the knapsack should not exceed the capacity C. One has to put these items in a knapsack of capacity C such that the knapsack has the maximum value. Given values and weights of n different items. One of the prominent combinatorial optimization problems is the Knapsack problem Java.
