your program should read the file knapsack.data from the current directory. This file
should contain a set of weight/value/name triples, such as the following:
1 10 mouse
2 25 cellphone
5 40 tablet
7 100 laptop
In the above file, there are four items: a mouse with a weight of 1 and value of 10; a
cellphone with a weight of 2 and value of 25; and so on.
After reading knapsack.data and storing the data in arrays, you should call a function (I
called this MaxVal(x) in class) for computing the maximum value that can be loaded into a
knapsack with a weight capacity of x. MaxVal(x) works by returning 0 if x <= 0, otherwise
returning the maximum of (v0+MaxVal(x-w0), v1+MaxVal(x-w1), ..., Vn+MaxVal(x-wn))
where each (vi,wi) is the value and weight of item i, and the maximum is computed over all
items where wi <= x (i.e. where item i can fit in a bag with capacity x). This is the algorithm
that was discussed in class.
In addition to printing the maximum possible value, you should print how many of
each item should be put in the bag.