Exhaustive search Approach
Prof. Dr. K. Adisesha
53
0/1 Knapsack Problem:
Given weights and profits of N items, put these items in a knapsack of capacity W. The
possible solutions in such a way that there are no remaining items left whose weight is
less than the remaining capacity of the knapsack. With maximum profit.
Input: Profits[] = {60, 100, 120, 50}
Weights[] = {10, 20, 30, 40}, W = 40
Output:
10: 60, 20: 100,
10: 60, 30: 120,
Maximum Profit = 180
Explanation: Maximum profit from all the possible
solutions is 180
Input: Profits[] = {60, 100, 120, 50}
Weights[] = {10, 20, 30, 40}, W = 50
Output:
10: 60, 20: 100,
10: 60, 30: 120,
20: 100, 30: 120,
Maximum Profit = 220
Explanation: Maximum profit from all the possible
solutions is 220