Don't like ads? PRO users don't see any ads ;-)
Guest

Code Sample-BBKnapsack

By: a guest on Nov 13th, 2011  |  syntax: Java  |  size: 0.57 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Code Sample. This code does not compile or run.
  2. if (cur.pos != -1) {
  3.         i = cur.pos;
  4.         curBest.remove(curBest.size() - 1);
  5.         total =  cur.curWgt - items[i].weight;
  6.         totVal = cur.curVal - items[i].value;
  7.        
  8.         if (i != items.length - 1) {
  9.           if(!fractional(total, totVal, i + 1, items, weight, bestVal)) {
  10.             cuts++;
  11.             continue;
  12.           }
  13.  
  14.           else {
  15.             curWgt = cur.curWgt - items[cur.pos].weight;
  16.             curVal = cur.curVal - items[cur.pos].value;
  17.             i = cur.pos + 1;
  18.