CalcWorldHub
Free online calculator · no signup

Zero one knapsack selection calculator

Select a maximum-value subset of indivisible items under an integer weight capacity using the zero-one knapsack model.

4,000 tools
Zero one knapsack selection calculator — Positive integer item weights, Matching nonnegative item values, Integer weight capacity and calculation method
Zero one knapsack selection calculator: inputs and calculation method.

How to use this calculator

Select a maximum-value subset of indivisible items under an integer weight capacity using the zero-one knapsack model.

  1. Enter Positive integer item weights, Matching nonnegative item values, Integer weight capacity. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

How the Zero one knapsack selection calculator works

Select a maximum-value subset of indivisible items under an integer weight capacity using the zero-one knapsack model.

Inputs and units

  • Positive integer item weights: Positive whole item weights in list order.
  • Matching nonnegative item values: Matching nonnegative values in the same order as weights.
  • Integer weight capacity: Nonnegative whole weight capacity; zero permits only the empty selection.

Formula and method

maximize Σ vi xi subject to Σ wi xi ≤ capacity and xi ∈ {0,1}

Worked example

Weights 2,3,4,5 and values 3,4,5,8 with capacity 8 have optimum items 2 and 4: weight 3+5=8 and value 4+8=12. Enumerating all 16 subsets confirms no feasible subset has higher value.

Interpreting the result

Item numbers refer to positions in the entered lists. Each item can be selected once, and unused capacity is allowed.

Assumptions and limits

Weights and capacity are integers; values are nonnegative. This is not a fractional or unlimited-quantity knapsack. Runtime limits bound list and capacity sizes.

Sources and method

Frequently asked questions

Can I take half an item?

No. Every choice is binary: include the whole item once or leave it out.

Is the highest value-to-weight ratio always optimal?

No. A greedy ratio ordering solves a different fractional problem; indivisible items can require a different combination.

How do I use the Zero one knapsack selection calculator?

Enter Positive integer item weights, Matching nonnegative item values, Integer weight capacity. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Zero one knapsack selection?

Weights 2,3,4,5 and values 3,4,5,8 with capacity 8 have optimum items 2 and 4: weight 3+5=8 and value 4+8=12. Enumerating all 16 subsets confirms no feasible subset has higher value.

What does the Zero one knapsack selection calculator calculate?

Select a maximum-value subset of indivisible items under an integer weight capacity using the zero-one knapsack model.