20 November 2024 07:12:55 PM knapsack_values_test(): C++ version, Test knapsack_values(). Problem #1 Number of items is 5 Knapsack weight limit is 26 Item 0/1 Value Weight Value/Weight 0 0 24 12 2 1 1 13 7 1.86 2 1 23 11 2.09 3 1 15 8 1.88 4 0 16 9 1.78 Taken 3 51 26 1.96 Problem #2 Number of items is 6 Knapsack weight limit is 190 Item 0/1 Value Weight Value/Weight 0 1 50 56 0.893 1 1 50 59 0.847 2 0 64 80 0.8 3 0 46 64 0.719 4 1 50 75 0.667 5 0 5 17 0.294 Taken 3 150 190 0.789 Problem #3 Number of items is 6 Knapsack weight limit is 20 Item 0/1 Value Weight Value/Weight 0 1 175 10 17.5 1 1 90 9 10 2 0 20 4 5 3 0 50 2 25 4 1 10 1 10 5 0 200 20 10 Taken 3 275 20 13.8 Problem #4 Number of items is 7 Knapsack weight limit is 50 Item 0/1 Value Weight Value/Weight 0 1 70 31 2.26 1 0 20 10 2 2 0 39 20 1.95 3 1 37 19 1.95 4 0 7 4 1.75 5 0 5 3 1.67 6 0 10 6 1.67 Taken 2 107 50 2.14 Problem #5 Number of items is 7 Knapsack weight limit is 170 Item 0/1 Value Weight Value/Weight 0 1 442 41 10.8 1 0 525 50 10.5 2 0 511 49 10.4 3 1 593 59 10.1 4 0 546 55 9.93 5 0 564 57 9.89 6 1 617 60 10.3 Taken 3 1652 160 10.3 Problem #6 Number of items is 8 Knapsack weight limit is 104 Item 0/1 Value Weight Value/Weight 0 1 350 25 14 1 0 400 35 11.4 2 1 450 45 10 3 1 20 5 4 4 1 70 25 2.8 5 0 8 3 2.67 6 1 5 2 2.5 7 1 5 2 2.5 Taken 6 900 104 8.65 Problem #7 Number of items is 10 Knapsack weight limit is 67 Item 0/1 Value Weight Value/Weight 0 1 505 23 22 1 0 352 26 13.5 2 0 458 20 22.9 3 1 220 18 12.2 4 0 354 32 11.1 5 0 414 27 15.3 6 0 498 29 17.2 7 1 545 26 21 8 0 473 30 15.8 9 0 543 27 20.1 Taken 3 1270 67 19 Problem #8 Number of items is 10 Knapsack weight limit is 165 Item 0/1 Value Weight Value/Weight 0 1 92 23 4 1 1 57 31 1.84 2 1 49 29 1.69 3 1 68 44 1.55 4 0 60 53 1.13 5 1 43 38 1.13 6 0 67 63 1.06 7 0 84 85 0.988 8 0 87 89 0.978 9 0 72 82 0.878 Taken 5 309 165 1.87 Problem #9 Number of items is 15 Knapsack weight limit is 750 Item 0/1 Value Weight Value/Weight 0 1 135 70 1.93 1 0 139 73 1.9 2 1 149 77 1.94 3 0 150 80 1.88 4 1 156 82 1.9 5 0 163 87 1.87 6 1 173 90 1.92 7 1 184 94 1.96 8 1 192 98 1.96 9 0 201 106 1.9 10 0 210 110 1.91 11 0 214 113 1.89 12 0 221 115 1.92 13 1 229 118 1.94 14 1 240 120 2 Taken 8 1458 749 1.95 Problem #10 Number of items is 24 Knapsack weight limit is 6404180 Item 0/1 Value Weight Value/Weight 0 1 825594 382745 2.16 1 1 1677009 799601 2.1 2 0 1676628 909247 1.84 3 1 1523970 729069 2.09 4 1 943972 467902 2.02 5 1 97426 44328 2.2 6 0 69666 34610 2.01 7 0 1296457 698150 1.86 8 0 1679693 823460 2.04 9 1 1902996 903959 2.11 10 1 1844992 853665 2.16 11 0 1049289 551830 1.9 12 1 1252836 610856 2.05 13 0 1319836 670702 1.97 14 0 953277 488960 1.95 15 1 2067538 951111 2.17 16 0 675367 323046 2.09 17 0 853655 446298 1.91 18 0 1826027 931161 1.96 19 0 65731 31385 2.09 20 0 901489 496951 1.81 21 1 577243 264724 2.18 22 1 466257 224916 2.07 23 1 369261 169684 2.18 Taken 12 13549094 6402560 2.12 knapsack_values_test(): Normal end of execution. 20 November 2024 07:12:55 PM