✓
Best Case
O(n × W)
All
(n+1)×(W+1) cells are still filled in the standard bottom-up DP table.!DOCTYPE html>
| Step | Phase | Cell | Item | Decision | Value | Explanation |
|---|
K[i-1,w]v_i + K[i-1,w-w_i] if w_i ≤ w(n+1)×(W+1) cells are still filled in the standard bottom-up DP table.nW.O(W).| Approach | Main idea | Time | Space | Optimal for 0/1 knapsack? | What this project shows |
|---|
O(nW).O(n).O(W) space. That is real, but it is not the one being visualized here.2^n, which is why it becomes impractical much faster.Open the first demo and press Step through greedy a few times. Students will see the tempting local choices first.
Then press Show DP decision. This lets you explain that DP checks both include and exclude before storing the better value.
After the first demo, move to the worked example, sorting/searching section, and paradigm demo to reinforce the same idea with simpler wording.
Dynamic Programming.n items, the tree has about 2^(n+1)-1 nodes and 2ⁿ leaves.