Concept Flow - 0 1 Knapsack Problem
Start with empty knapsack
For each item i
For each weight w from 0 to max W
Check if item i fits (weight[i
Yes No
Include item i: value[i
Choose max of include/exclude
Store result in dp[i
Repeat for all items and weights
Final answer in dp[n
We fill a table step-by-step deciding for each item and weight whether to include or exclude the item to maximize value.
