Experiment No 4 Write Up
Experiment No 4 Write Up
04
Aim: Write a program for 0/1 knapsack problem, analyze it, and find time
complexity.
Theory:
The 0/1 knapsack problems involves selecting items with weights and
values to maximize values without exceeding a weight limit solutions
include dynamic programming, which iteratively fills a table to find the
optimal solutions. It is called “0/1” because items cannot be partially
taken ,they are either included entirely or not at all included .
For example, we have two items having weights 2kg and 3kg,
respectively. If we pick the 2kg item then we cannot pick 1kg item from
the 2kg item (item is not divisible); we must pick the 2kg item
completely. This is a 0/1 knapsack problem in which either we pick the
item completely or we will not pick that item. The 0/1 knapsack problem
is solved by the dynamic programming.
Time Complexity: O (N * W)
PROGRAM:
Conclusion:
Hence, We successfully implemented Knapsack problem.