Suppose you are choosing cloud instances within a fixed capacity. For each instance, you must either leave it out or take it once. That is the 0/1 constraint: extra capacity does not let you take another copy of the same instance. section 7.1
In a dynamic-programming table, T[i, j] is the best value using the first i items with capacity j. If item i fits, compare skipping it, T[i−1, j], with taking it, vi + T[i−1, j−wi]. Both choices consult the previous row, where item i is not available again. If it does not fit, copy the value above. section 7.1
A choice at capacity 3
The second instance costs 2 and has value 3. Skipping it gives 2; taking it leaves capacity 1, whose previous-row value is 2. Choose 3 + 2 = 5. section 7.1
Figure 7.3 Visualization of the math used to evaluate cell T[2, 3] (circled in green) on the second row (w2 = 2, v2 = 3). The algorithm resolves a binary choice by executing a maximum value comparison between two paths. The exclusion path inherits the value directly above (T[1, 3] = 2). The active inclusion path accepts the new instance's throughput value (v2 = 3, highlighted in the red solid box) and subtracts its weight from the current capacity (3 - 2 = 1), forcing a pointer lookup to the previous row at column 1 (T[1, 1] = 2, highlighted by the red dotted circle). The combined value of 5 outperforms the exclusion path, updating the cell state.
Follow the two previous-row lookups to see why taking the instance wins without taking it twice. section 7.1
