The optimal value is only half the story; traceback recovers the subset that achieves it. The path moves upward through the table, marking rows where an item was taken. This lesson turns the DP value into a concrete certificate and states the pseudo-polynomial scope honestly.

highlighted = computed this step

Traceback path

The traceback starts at the final cell and follows 4 cells. Why: each step asks whether the current row changed the value compared with the row above. If the value did not change, the current item was unnecessary for this optimum; if it did, the path moves to the remaining capacity after taking that item.

traceback from final state\text{traceback from final state}
TracebackThe traceback path and chosen items are recomputed from the final table.Traceback01234567cap-00000000(1,1)01111111*(3,4)01145555*(4,5)01145669(5,7)01145789path cell* chosen rowchosen items: #2 (3,4), #3 (4,5)

Chosen items

The chosen items are item 2 and item 3. Why: those are the rows where traceback takes the item, so they turn the table's value into an actual subset. This matters because an optimal value alone is not a packing plan; the certificate needs to show which items realize it.

chosen items 2,3\text{chosen items }2,3
TracebackThe traceback path and chosen items are recomputed from the final table.Traceback01234567cap-00000000(1,1)01111111*(3,4)01145555*(4,5)01145669(5,7)01145789path cell* chosen rowchosen items: #2 (3,4), #3 (4,5)

Subset certificate

Their total weight is 7, equal to capacity 7, and total value is 9. Why: the chosen subset both fits the capacity and achieves the table's optimum. Feasibility and value meet in the same object, so the traceback is the constructive certificate behind the final DP cell.

value=9\text{value}=9
TracebackThe traceback path and chosen items are recomputed from the final table.Traceback01234567cap-00000000(1,1)01111111*(3,4)01145555*(4,5)01145669(5,7)01145789path cell* chosen rowchosen items: #2 (3,4), #3 (4,5)

Scope of DP

This DP table is exact here, but table size grows with item count times capacity magnitude. Why: knapsack DP is pseudo-polynomial, not a small-table guarantee for every encoding. That scope statement is part of the honesty boundary: the arithmetic is exact for this instance, while the method's running size depends on the numeric capacity.

exact table, pseudo-polynomial size\text{exact table, pseudo-polynomial size}
TracebackThe traceback path and chosen items are recomputed from the final table.Traceback01234567cap-00000000(1,1)01111111*(3,4)01145555*(4,5)01145669(5,7)01145789path cell* chosen rowchosen items: #2 (3,4), #3 (4,5)

Diagram note

Path cells show the traceback route; starred rows mark chosen items. The display connects two claims: the final cell gives the best value, and the path names a subset that attains it. The exact proof is for zero-one integer knapsack with this pinned item set and capacity. Pixel positions are rounded for layout; every number shown is exact.

traceback turns value into a subset\text{traceback turns value into a subset}
TracebackThe traceback path and chosen items are recomputed from the final table.Traceback01234567cap-00000000(1,1)01111111*(3,4)01145555*(4,5)01145669(5,7)01145789path cell* chosen rowchosen items: #2 (3,4), #3 (4,5)