public class Knapsack01DynamicOneSolution
extends java.lang.Object
Compilation: javac Knapsack.java
Execution: java Knapsack N W
Generates an instance of the 0/1 knapsack problem with N items
and maximum weight W and solves it in time and space proportional
to N * W using dynamic programming.
For testing, the inputs are generated at random with weights between 0
and W, and profits between 0 and 1000.
% java Knapsack 6 2000
item profit weight take
1 874 580 true
2 620 1616 false
3 345 1906 false
4 369 1942 false
5 360 50 true
6 470 294 true