CIS 435, Spring 2002, Jim Calvin
Homework #10 Solutions
16.23
Suppose we have
n
items with weights
w
1
≤
w
2
≤ ··· ≤
w
n
and values
v
1
≥
v
2
≥ ··· ≥
v
n
. The optimal algorithm is: take items 1
,
2
,... ,k
where
k
is
the frst integer such that
w
1
+
w
2
+
···
+
w
k
+1
>L
. To show that this is optimal,
we frst show that an optimal solution contains item 1 (assuming that
L>w
1
). IF
not, replace any chosen item with 1 and the weight is no greater and the value is
at least as high. Thus there is an optimal solution containing item 1. An optimal
solution to the subproblem with items 2 through
n
must contain item 2, and so on.
16.24
ProF. Midas should drive as Far as he can on each tank oF gas without
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '09
 ALEX
 Algorithms, optimal solution, Stop consonant, Prof. Midas

Click to edit the document details