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

Diff for /acm/acm2.cpp between version 1.1 and 1.3

version 1.1, 2005/02/16 07:00:56 version 1.3, 2005/02/16 07:19:57
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.putItem(2,2);  knapsackOne.putitem(70,70);
         knapsackOne.putItem(3,3);  knapsackOne.putitem(76,76);
         knapsackOne.putItem(4,4);  knapsackOne.putitem(55,55);
         knapsackOne.putItem(5,5);  knapsackOne.putitem(17,17);
         knapsackOne.putItem(7,7);  knapsackOne.putitem(70,70);
         knapsackOne.putItem(8,8);  knapsackOne.putitem(77,77);
         knapsackOne.putItem(9,9);  knapsackOne.putitem(52,52);
         knapsackOne.putItem(10,10);  knapsackOne.putitem(81,81);
         knapsackOne.putItem(6,6);  knapsackOne.putitem(11,11);
   knapsackOne.putitem(31,31);
   knapsackOne.putitem(57,57);
   knapsackOne.putitem(47,47);
   knapsackOne.putitem(93,93);
   knapsackOne.putitem(53,53);
   knapsackOne.putitem(83,83);
   knapsackOne.putitem(33,33);
   knapsackOne.putitem(1,1);
   knapsackOne.putitem(59,59);
   knapsackOne.putitem(29,29);
   knapsackOne.putitem(33,33);
   knapsackOne.putitem(78,78);
   knapsackOne.putitem(79,79);
   knapsackOne.putitem(37,37);
   knapsackOne.putitem(26,26);
   knapsackOne.putitem(83,83);
   
  
 // 47591 17  
         knapsackOne.store_item_array();         knapsackOne.store_item_array();
  
  
Line 449 
Line 465 
  
 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  
changed lines
  Added in v.1.3

Rizwan Kassim
Powered by
ViewCVS 0.9.2