Filling the Table
Take or Leave
Every non-base DP cell compares two exact choices: leave the current item or take it. This lesson works one cell completely so the recurrence becomes an interpretable argument, not just a formula. The highlighted table shows the result cell and its two predecessors.
Leave option
Leaving the item gives value 5. Why: if the current item is not chosen, the best value cannot depend on it at all. The recurrence therefore looks to the previous row at the same capacity, which means the same bag space is available but fewer items may be used.
Take option
Taking the item uses previous value 4 plus item value 5, giving 9. Why: taking an item spends capacity before earning value. The lookup goes to the previous row so the same item is not counted again, and it goes to the reduced capacity because the item now occupies part of the bag.
Result cell
The cell value is 9. Why: every feasible subset for this prefix either takes the current item or leaves it, so the better of those two exact cases is the whole answer for the cell. The highlighted cell is therefore a local certificate for one subproblem.
Diagram note
The legend identifies the result cell, the leave predecessor, and the take predecessor. Those three roles are the whole recurrence in miniature: compare the old best value with the value of taking the item after freeing the required capacity. No estimate or search shortcut is hidden in the picture. Pixel positions are rounded for layout; every number shown is exact.