The DP table begins with a row for using no items. The next row shows how the first item changes every capacity. These rows make the recurrence concrete before the full table is filled.

highlighted = computed this step

Base row

With no items, every capacity has value 0. Why: there is nothing available to put in the bag.

dp[0,w]=0dp[0,w]=0
Base and first rowsThe full DP table is recomputed, but only the base row and first item row are displayed.Base and first item01234567cap-00000000(1,1)01111111

First item row

After the first item, each positive capacity can reach value 1. Why: the item fits as soon as capacity reaches its weight.

first row value 1\text{first row value }1
Base and first rowsThe full DP table is recomputed, but only the base row and first item row are displayed.Base and first item01234567cap-00000000(1,1)01111111

Diagram note

The displayed prefix is clipped from the recomputed DP table; only the first two rows are shown here. Pixel positions are rounded for layout; every number shown is exact.

base cases anchor the table\text{base cases anchor the table}
Base and first rowsThe full DP table is recomputed, but only the base row and first item row are displayed.Base and first item01234567cap-00000000(1,1)01111111