(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.4

version 1.1.1.1, 2005/02/16 07:00:56 version 1.4, 2005/02/16 07:21:28
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(70,70);
   knapsackOne.putItem(76,76);
   knapsackOne.putItem(55,55);
   knapsackOne.putItem(17,17);
   knapsackOne.putItem(70,70);
   knapsackOne.putItem(77,77);
   knapsackOne.putItem(52,52);
   knapsackOne.putItem(81,81);
   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(1,1);
         knapsackOne.putItem(2,2);  knapsackOne.putItem(59,59);
         knapsackOne.putItem(3,3);  knapsackOne.putItem(29,29);
         knapsackOne.putItem(4,4);  knapsackOne.putItem(33,33);
         knapsackOne.putItem(5,5);  knapsackOne.putItem(78,78);
         knapsackOne.putItem(7,7);  knapsackOne.putItem(79,79);
         knapsackOne.putItem(8,8);  knapsackOne.putItem(37,37);
         knapsackOne.putItem(9,9);  knapsackOne.putItem(26,26);
         knapsackOne.putItem(10,10);  knapsackOne.putItem(83,83);
         knapsackOne.putItem(6,6);  
  
 // 47591 17  
         knapsackOne.store_item_array();         knapsackOne.store_item_array();
  
  
Line 449 
Line 464 
  
 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.4

Rizwan Kassim
Powered by
ViewCVS 0.9.2