(file) Return to acm2.cpp CVS log (file) (dir) Up to [RizwankCVS] / acm

Diff for /acm/acm2.cpp between version 1.1.1.1 and 1.2

version 1.1.1.1, 2005/02/16 07:00:56 version 1.2, 2005/02/16 07:17:25
Line 8 
Line 8 
 // their parent object was in the priority queue, so static sized // their parent object was in the priority queue, so static sized
 // arrays were used // arrays were used
  
 #define MAX_ITEMS 25  #define MAX_ITEMS 55
  
 using namespace std; using namespace std;
  
Line 398 
Line 398 
         printf("============================ KNAPSACK ONE ================================\n");         printf("============================ KNAPSACK ONE ================================\n");
         backpack knapsackOne;         backpack knapsackOne;
  
         knapsackOne.initBackpack(10,18); // 5 total items, 17 total weight          knapsackOne.initBackpack(25,200); // 5 total items, 17 total weight
         knapsackOne.putItem(1,1);  knapsackOne.packitem(70,70);
         knapsackOne.putItem(2,2);  knapsackOne.packitem(76,76);
         knapsackOne.putItem(3,3);  knapsackOne.packitem(55,55);
         knapsackOne.putItem(4,4);  knapsackOne.packitem(17,17);
         knapsackOne.putItem(5,5);  knapsackOne.packitem(70,70);
         knapsackOne.putItem(7,7);  knapsackOne.packitem(77,77);
         knapsackOne.putItem(8,8);  knapsackOne.packitem(52,52);
         knapsackOne.putItem(9,9);  knapsackOne.packitem(81,81);
         knapsackOne.putItem(10,10);  knapsackOne.packitem(11,11);
         knapsackOne.putItem(6,6);  knapsackOne.packitem(31,31);
   knapsackOne.packitem(57,57);
 // 47591 17  knapsackOne.packitem(47,47);
   knapsackOne.packitem(93,93);
   knapsackOne.packitem(53,53);
   knapsackOne.packitem(83,83);
   knapsackOne.packitem(33,33);
   knapsackOne.packitem(1,1);
   knapsackOne.packitem(59,59);
   knapsackOne.packitem(29,29);
   knapsackOne.packitem(33,33);
   knapsackOne.packitem(78,78);
   knapsackOne.packitem(79,79);
   knapsackOne.packitem(37,37);
   knapsackOne.packitem(26,26);
   knapsackOne.packitem(83,83);
         knapsackOne.store_item_array();         knapsackOne.store_item_array();
  
  
Line 449 
Line 462 
  
 Whats interesting is that we can keep the various ratio calculations, as we WOULD rather insert an item of 10 lbs rather than 1 Whats interesting is that we can keep the various ratio calculations, as we WOULD rather insert an item of 10 lbs rather than 1
 We just equate weight and value later on! (Or set a fixed ratio of 1) We just equate weight and value later on! (Or set a fixed ratio of 1)
                   knapsack insert (value,value)
  
                 This was max 2^10-1 with only 47 nodes and 33 splits.                 This was max 2^10-1 with only 47 nodes and 33 splits.
  
   And lets try with a random set of 25 numbers!
   70,76,55,17,70,77,52,81,11,31,57,47,93,53,83,33,1,59,29,33,78,79,37,26,83 ==> 200
   
   
   
   then 50:
   186,130,132,108,112,39,90,88,105,172,50,46,125,79,22,192,139,132,77,195,21,129,134,76,179,89,32,55,61,160,49,191,153,86,45,16,196,109,1,178,51,104,40,88,135,100,108,182,30,48  => 1470
   
   
   
   
                 */                 */
  


Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

Rizwan Kassim
Powered by
ViewCVS 0.9.2