applications
Class IterativeDPKnapsack

java.lang.Object
  |
  +--applications.IterativeDPKnapsack

public class IterativeDPKnapsack
extends java.lang.Object


Constructor Summary
IterativeDPKnapsack()
           
 
Method Summary
static void knapsack(int[] profit, int[] weight, int knapsackCapacity, int[][] f)
          iterative method to solve dynamic programming recurrence computes f[1][c] and f[i][y], 2 <= i <= numberOfObjects, 0 <= y <= knapsackCapacity
static void main(java.lang.String[] args)
          test program
static void traceback(int[][] f, int[] weight, int knapsackCapacity, int[] x)
          compute solution vector x
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IterativeDPKnapsack

public IterativeDPKnapsack()
Method Detail

knapsack

public static void knapsack(int[] profit,
                            int[] weight,
                            int knapsackCapacity,
                            int[][] f)
iterative method to solve dynamic programming recurrence computes f[1][c] and f[i][y], 2 <= i <= numberOfObjects, 0 <= y <= knapsackCapacity
Parameters:
profit[1:profit.length - - 1] gives object profits
weight[1:weight.length-1] - gives object weights
knapsackCapacity - is the knapsack capacity

traceback

public static void traceback(int[][] f,
                             int[] weight,
                             int knapsackCapacity,
                             int[] x)
compute solution vector x

main

public static void main(java.lang.String[] args)
test program