Mental Model
We want to pick items with values and weights to maximize value without exceeding weight limit. Each item can be chosen only once.
Analogy: Imagine packing a backpack for a trip. You have limited space and many items with different importance and sizes. You want to pack the most valuable combination without overloading.
Knapsack capacity: 5 Items: [Item0: weight=2, value=3] [Item1: weight=3, value=4] [Item2: weight=4, value=5] Table rows = items considered Table columns = weight limits from 0 to capacity DP Table (initial): W 0 1 2 3 4 5 I0 0 0 0 0 0 0 I1 0 0 0 0 0 0 I2 0 0 0 0 0 0
