0-1 Knapsack

This is a Java dynamic programming implementation of the 0-1 knapsack problem. The fractional knapsack problem can be solved using the greedy algorithm (see Cormen pp. 425).

How to run it?

  1. Download Knapsack.java and place in directory 'mg'
  2. Compile and execute this Java file
  3. The execution does not require any arguments and the standard output should be easy to follow. Different data can be defined in: int[] vi and int[] wi in the main function

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Back to main page