Package org.jbpt.mining
Class Knapsack01DynamicOneSolution
- java.lang.Object
-
- org.jbpt.mining.Knapsack01DynamicOneSolution
-
public class Knapsack01DynamicOneSolution extends java.lang.ObjectCompilation: 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
-
-
Constructor Summary
Constructors Constructor Description Knapsack01DynamicOneSolution()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidmain(java.lang.String[] args)static boolean[]solve(int[] profit, int[] weight, int W)
-