Home / Calculators / 0/1 Knapsack Solver
Free online tool

0/1 Knapsack Solver

Find one selection with maximum total value for the 0/1 knapsack problem, using integer weights and capacity. Processing takes place locally in your browser.

Start using

0/1 Knapsack Solver

Find one selection with maximum total value for the 0/1 knapsack problem, using integer weights and capacity.

Enter one item per line as name,weight,value, using ASCII commas. Names must be unique after trimming and cannot contain commas. Surrounding spaces are accepted; blank lines are ignored. Values may be decimals using a point.

A,2,6
B,3,10
C,4,12

Paste the three item lines below, set capacity separately to 5, then calculate: maximum value 16, selection A, B. Copy copies the result; Clear also empties the capacity field.

Use 1–200 items; capacity is an integer 1–5000; each weight is an integer 1–capacity; each value is a nonblank finite number 0–1000000000. A heavier item rejects the entire input. The text limit is 500000 UTF-16 code units. Each item is selected at most once. Only maximum value and selected names are shown, not total weight. On an exact tie, later items are skipped, so input order can change the chosen optimal set; there is no minimum-weight tie-breaker. All-zero values give 0 and an empty selection. Decimal arithmetic can round; scale precise monetary values to integer units.

Processing takes place locally in your browser.