

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


COMP202 Class Exam 2 Complexity of Algorithms 28 March 2007
[NB: This examination contributes 10% to your overall final course grade.]
Answer all questions!
gcd(a, b) = gcd(b, a mod b), provided b 6 = 0.
(b) a 224 63 35 28 7 b 63 35 28 7 0 Hence, gcd(224, 63) = 7.
item a b c d e f weight 2 1 3 6 4 5 benefit 3 4 5 18 10 6 vi (^32 4 53 3 2 )
Then we select items in (decreasing) order of their value indices until we fill up the knapsack (including, possibly, some fractional amount of an item during the last step). Also note that 2 12 > 53 > 32 > 65. Hence, the order in which we consider the items is b, d, e, c, a, f. Items b, d, and e together have a total weight of 11 and a total benefit of
H → K → C → I and
I → E → K → C → H.