CH 35
CH 35
CH 35
Exercise 35.1-1
We could select the graph that consists of only two vertices and a single
edge between them. Then, the approximation algorithm will always select both
of the vertices, whereas the minimum vertex cover is only one vertex. more
generally, we could pick our graph to be k edges on a graph with 2k vertices so
that each connected component only has a single edge. In these examples, we
will have that the approximate solution is off by a factor of two from the exact
one.
Exercise 35.1-2
It is clear that the edges picked in line 4 form a matching, since we can only
pick edges from E 0 , and the edges in E 0 are precisely those which don’t share an
endpoint with any vertex already in C, and hence with any already-picked edge.
Moreover, this matching is maximal because the only edges we don’t include are
the ones we removed from E 0 . We did this because they shared an endpoint
with an edge we already picked, so if we added it to the matching it would no
longer be a matching.
Exercise 35.1-3
1
that set we picked, add a single vertex to L whose only neighbor is the one in
R that we picked. This clearly makes R uniform.
Also, lets see what happens as we apply the heuristic. Note that each vertex
in R only has at most a single vertex of each degree in L. This means that as
we remove vertices from L along with their incident edges, we will always have
that the highest degree vertex remaining in L is greater or equal to the highest
degree vertex in R. This means that we can always, by this heuristic, continue
to select vertices from L instead of R. So, when we are done, we have selected,
by this heuristic, that our vertex cover is all of L.
Lastly, we need to Pshow that L is big enough relative to R. The size of L
n
is greater or equal to i=2 b ni c where we ignore any of the degree 1 vertices
we may of added
R n+1 to L in our last step. This sum can be bounded below by
the integral i=2 nx dx by formula (A.12). Elementary calculus tells us that this
integral evaluates to n(lg(n + 1) − 1), so, we can clearly select n > 8 to make it
so that
2|R| = 2n
< n(lg(8 + 1) − 1)
≤ n(lg(n + 1) − 1)
Z n+1
n
= dx
i=2 x
n
X n
≤ b c
i=2
i
≤ |L|
Since we selected L as our vertex cover, and L is more than twice the size of
the vertex cover R, we do not have a 2- approximation using this heuristic. In
fact, we have just shown that this heuristic is not a ρ approximation for any
constant ρ.
Exercise 35.1-4
2
optimal. We may now write down the greedy approach, given in the algorithm
GREEDY-VERTEX-COVER:
Algorithm 1 GREEDY-VERTEX-COVER(G)
1: V 0 = ∅
2: let L be a list of all the leaves of G
3: while V 6= ∅ do
4: if |V | == 1 or 0 then
5: return V 0
6: end if
7: let v be a leaf of G = (V, E), and {v, u} be its incident edge
8: V =V −v
9: V0 =V0∪u
10: for each edge {u, w} ∈ E incident to u do
11: if dw == 1 then
12: L.insert(w)
13: end if
14: E = E − {u, w}
15: end for
16: V =V −u
17: end while
As it stands, we can’t be sure this runs in linear time since it could take O(n)
time to find a leaf each time we run line 7. However, with a clever implementa-
tion we can get around this. Keep in mind that a vertex either starts as a leaf,
or becomes a leaf when an edge connecting it to a leaf is removed from it. We’ll
maintain a list L of current leaves in the graph. We can find all leaves initially
in linear time in line 2. Assume we are using an adjacency list representation.
In line 4 we check if |V | is 1 or 0. If it is, then we are done. Otherwise, the tree
has at least 2 vertices which implies that it has a leaf. We can get our hands
on a leaf in constant time in line 7 by popping the first element off of the list
L, which maintains our leaves. We can find the edge {u, v} in constant time by
examining v’s adjacency list, which we know has size 1. As described above,
we know that v isn’t contained in an optimal solution. However, since {u, v}
is an edge and at least one of its endpoints must be contained in V 0 , we must
necessarily add u. We can remove v from V in constant time, and add u to V 0
in constant time. Line 10 will only execute once for each edge, and since G is a
tree we have |E| = |V | − 1. Thus, the total contribution of the for-loop of line
10 is linear. We never need to consider edges adjacent to u since u ∈ V 0 . We
check the degrees as we go, adding a vertex to L if we discover it has degree
1, and hence is a leaf. We can update the attribute dw for each w in constant
time, so this doesn’t affect the runtime. Finally, we remove u from V and never
again need to consider it.
3
Exercise 35.1-5
It does not imply the existence of an approximation algorithm for the max-
imum size clique. Suppose that we had in a graph of size n, the size of the
smallest vertex cover was k, and we found one that was size 2k. This means
that in the compliment, we found a clique of size n − 2k, when the true size of
the largest clique was n − k. So, to have it be a constant factor approximation,
we need that there is some λ so that we always have n−2k ≥ λ(n−k). However,
if we had that k was close to n2 for our graphs, say n2 − , then we would have
to require 2 ≥ λ n2 + . Since we can make stay tiny, even as n grows large,
this inequality cannot possibly hold.
Exercise 35.2-1
Suppose that c(u, v) < 0 and w is any other vertex in the graph. Then, to
have the triangle inequality satisfied, we need c(w, u) ≤ c(w, v) + c(u, v). Now
though, subtract c(u, v) from both sides, we get c(w, v) ≥ c(w, u) − c(u, v) >
c(w, u) + c(u, v) so, it is impossible to have c(w, v) ≤ c(w, u) + c(u, v) as the
triangle inequality would require.
Exercise 35.2-2
Let m be some value which is larger than any edge weight. If c(u, v) denotes
the cost of the edge from u to v, then modify the weight of the edge to be
H(u, v) = c(u, v) + m. (In other words, H is our new cost function). First we
show that this forces the triangle inequality to hold. Let u, v, and w be ver-
tices. Then we have H(u, v) = c(u, v) + m ≤ 2m ≤ c(u, w) + m + c(w, v) + m =
H(u, w) + H(w, v). Note: it’s important that the weights of edges are nonneg-
ative.
Next we must consider how this affects the weight of an optimal tour. First,
any optimal tour has exactly n edges (assuming that the input graph has exactly
n vertices). Thus, the total cost added to any tour in the original setup is nm.
Since the change in cost is constant for every tour, the set of optimal tours must
remain the same.
To see why this doesn’t contradict Theorem 35.3, let H denote the cost of
a solution to the transformed problem found by a ρ-approximation algorithm
and H ∗ denote the cost of an optimal solution to the transformed problem.
Then we have H ≤ ρH ∗ . We can now transform back to the original problem,
and we have a solution of weight C = H − nm, and the optimal solution has
weight C ∗ = H ∗ − nm. This tells us that C + nm ≤ ρ(C ∗ + nm), so that
C ≤ ρ(C ∗ ) + (ρ − 1)nm. Since ρ > 1, we don’t have a constant approximation
ratio, so there is no contradiction.
Exercise 35.2-3
4
From the chapter on minimum spanning trees, recall Prim’s algorithm. That
is, a minimum spanning tree can be found by repeatedly finding the nearest ver-
tex to the vertices already considered, and adding it to the tree, being adjacent
to the vertex among the already considered vertices that is closest to it. Note
also, that we can recusively define the preorder traversal of a tree by saying
that we first visit our parent, then ourselves, then our children, before returning
priority to our parent. This means that by inserting vertices into the cycle in
this way, we are always considering the parent of a vertex before the child. To
see this, suppose we are adding vertex v as a child to vertex u. This means that
in the minimum spanning tree rooted at the first vertex, v is a child of u. So,
we need to consider u first before considering v, and then consider the vertex
that we would of considered after v in the previous preorder traversal. This
is precisely achieved by inserting v into the cycle in such a manner. Since the
property of the cycle being a preorder traversal for the minimum spanning tree
constructed so far is maintained at each step, it is the case at the end as well,
once we have finished considering all the vertices. So, by the end of the process,
we have constructed the preorder traversal of a minimum spanning tree, even
though we never explicity built the spanning tree. It was shown in the sec-
tion that such a Hamiltonian cycle will be a 2 approximation for the cheapest
cycle under the given assumption that the weights satisfy the triangle inequality.
Exercise 35.2-4
Exercise 35.2-5
To show that the optimal tour never crosses itself, we will suppose that it
did cross itself, and then show that we could produce a new tour that had
lower cost, obtaining our contradiction because we had said that the tour we
5
had started with was optimal, and so, was of minimal cost. If the tour crosses
itself, there must be two pairs of vertices that are both adjacent in the tour, so
that the edge between the two pairs are crossing each other. Suppose that our
tour is S1 x1 x2 S2 y1 y2 S3 where S1 , S2 , S3 are arbitrary sequences of vertices, and
{x1 , x2 } and {y1 , y2 } are the two crossing pairs. Then, We claim that the tour
given by S1 x1 y2 Reverse(S2 )y1 x2 S3 has lower cost. Since {x1 , x2 , y1 , y2 } form
a quadrilateral, and the original cost was the sum of the two diagonal lengths,
and the new cost is the sums of the lengths of two opposite sides, this problem
comes down to a simple geometry problem.
Now that we have it down to a geometry problem, we just exercise our grade
school geometry muscles. Let P be the point that diagonals of the quadri-
lateral intersect. Then, we have that the vertices {x1 , P, y2 } and {x2 , P, y1 }
form triangles. Then, we recall that the longest that one side of a trian-
gle can be is the sum of the other two sides, and the inequality is strict if
the triangles are non-degenerate, as they are in our case. This means that
||x1 y2 || + ||x2 y1 || < ||x1 P || + ||P y2 || + ||x2 P || + ||P y1 || = ||x1 x2 || + ||y1 y2 ||. The
right hand side was the original contribution to the cost from the old two edges,
while the left is the new contribution. This means that this part of the cost has
decreased, while the rest of the costs in the path have remained the same. This
gets us that the new path that we constructed has strictly better cross, so we
must not of had an optimal tour that had a crossing in it.
Exercise 35.3-1
Since all of the words have no repeated letters, the first word selected will
be the one that appears earliest on among those with the most letters, this is
“thread”. Now, we look among the words that are left, seeing how many let-
ters that aren’t already covered that they contain. Since “lost” has four letters
that have not been mentioned yet,and it is first among those that do, that is
the next one we select. The next one we pick is “drain” because it is has two
unmentioned letters. This only leave “shun” having any unmentioned letters,
so we pick that, completing our set. So, the final set of words in our cover is
{thread, lost, drain, shun}.
Exercise 35.3-2
6
a set cover M of V 0 with at most k sets from F , then we could use {v|Sv ∈ M }
as a k-element vertex cover of G, a contradiction. Thus, G has a k element
vertex cover if and only if there is a k-element set cover of V 0 using elements
in F . Therefore set-covering is NP-hard, so we conclude that it is NP-complete.
Exercise 35.3-3
Algorithm 2 LINEAR-GREEDY-SET-COVER(F)
compute the sizes of every S ∈ F, storing them in S.size.
let A be an array of length maxS |S|, consisting of empty lists
for S ∈ F do
add S to A[S.size].
end for
let A.max be the index of the largest nonempty list in A.
let L be an array of length | ∪S∈F S| consisting of empty lists
for S ∈ F do
for ` ∈ S do
add S to L[`]
end for
end for
let C be the set cover that we will be selecting, initially empty.
let T be the set of letters that have been covered, initially empty.
while A.max > 0 do
Let S0 be any element of A[A.max].
add S0 to C
remove S0 from A[A.max]
for ` ∈ S0 \ T do
for S ∈ L[`] do
Remove S from A[A.size]
S.size = S.size -1
Add S to A[S.size]
if A[A.max] is empty then
A.max = A.max-1
end if
end for
add ` to T
end for
end while
Exercise 35.3-4
7
Each cx has cost at most
P 1, so we we can trivially replace the upper bound
in inequality (35.12) by x∈S cx ≤ |S| ≤ max{|S| : S ∈ F }. Combining
inequality (35.11) and the new (35.12), we have
X X X
|C| ≤ cx ≤ max{|S| : S ∈ F } = |C ∗ | max{|S| : S ∈ F }.
S∈C ∗ x∈S S∈C ∗
Exercise 35.3-5
Exercise 35.4-1
Any clause that contains both a variable and its negation is automatically
satisfied, since we always have x ∨ ¬x is true regardless of the truth value of
x. This means that if we separate out the clauses that contain no variable and
its negation, we have an 8/7ths approximation on those, and we have all of the
other clauses satisfied regardless of the truth assignments to variables. So, the
quality of the approximation just improves when we include the clauses con-
taining variables and their negation.
Exercise 35.4-2
As usual, we’ll assume that each clause contains only at most instance of
each literal, and that it doesn’t contain both a literal and its negation. Assign
each variable 1 with probability 1/2 and 0 with probability 1/2. Let Yi be the
random variable which takes on 1 if clause i is satisfied and 0 if it isn’t. The
probability that a clause fails to be satisfied is (1/2)k ≤ 1/2 where k is the
number of literals in the clause, so k ≥ 1. Thus, P (Yi ) = 1 − P (Yi ) ≥ 1/2. Let
Y be the total number of clauses satisfied and m be the total number of clauses.
Then we have
m
X
E[Y ] = E[Yi ] ≥ m/2.
i=1
8
Exercise 35.4-3
Lets consider the expected value of the weight of the cut. For each edge,
the probability that that edge crosses the cut is the probability that our coin
flips came up differently for the two vertices that are in the edge. This happens
with probability 12 . Therefore, by linearity of expectation, we know that the
expected weight of this cut is |E|
2 . We know that for the best cut we can make,
the weight will be bounded by the total number of edges in the graph, so we
have that the weight of the best cut is at most twice the expected weight of this
random cut.
Exercise 35.4-4
Exercise 35.5-1
9
anything that gets to be more than t.
Exercise 35.5-2
Otherwise, z must have been trimmed, which means there exists z 0 ∈ Li+1 such
y
that z/(1 + δ) ≤ z 0 ≤ z. Since δ = ε/2n, we have (1+ε/2n) 0
i+1 ≤ z ≤ z ≤ y, so
p + xi+1 p
i
≤ + xi+1 ≤ z + xi+1 ≤ p + xi+1 ,
(1 + ε/2n) (1 + ε/2n)i
so z + xi+1 well approximates p + xi+1 . If we don’t thin this out, then we
are done. Otherwise, there exists w ∈ Li+1 such that z+x i+1
1+δ ≤ w ≤ z + xi+1 .
Then we have
p + xi+1 z + xi+1
≤ ≤ w ≤ z + xi+1 ≤ p + xi+1 .
(1 + ε/2n)i+1 1 + ε/2n
Thus, claim holds for i + 1. By induction, the claim holds for all 1 ≤ i ≤ n,
so inequality (35.26) is true.
Exercise 35.5-3
As we have many times in the past, we’ll but on our freshman calculus hats.
d n
1+ =
dn 2n
d n lg(1+ 2n
)=
e
dn
−
n lg(1+ 2n
) n 2n 2
e 1+ + =
2n 1 + 2n
2
!
n lg(1+ 2n
) 1 + 2n − 2n
e =
1 + 2n
2
!
n lg(1+ 2n
) 1 + 2n + 2n
e =
1 + 2n
10
Since all three factors are always positive, the original expression is always
positive.
Exercise 35.5-4
We’ll rewrite the relevant algorithms for finding the smallest value, modify-
ing both TRIM and APPROX-SUBSET-SUM. The analysis is the same as that
for finding a largest sum which doesn’t exceed t, but with inequalities reversed.
Also note that in TRIM, we guarantee instead that for each y removed, there
exists z which remains on the list such that y ≤ z ≤ y(1 + δ).
Algorithm 3 TRIM(L, δ)
1: let m be the length of L
2: L0 = hym i
3: last = ym
4: for i = m − 1 downto 1 do
5: if yi < last/(1 + δ) then
6: append yi to the end of L0
7: last = yi
8: end if
9: end for
10: return L’
Algorithm 4 APPROX-SUBSET-SUM(S, t, ε)
1: n = |S|
Pn
2: L0 = h i=1 xi i
3: for i = 1 to n do
4: Li = MERGE-LISTS(Li−1 , Li−1 − xi )
5: Li = TRIM(Li , ε/2n)
6: return from Li every element that is less than t
7: end for
8: let z ∗ be the largest value in Ln
9: return z ∗
Exercise 35.5-5
11
by doing this, all of the work spent in the chapter to prove correctness of the
approximation scheme still holds. Each time that we put an element into Li ,
it could of been copied directly from Li−1 , in which case we copy the satellite
data as well. The only other possibility is that it is xi plus an entry in Li−1 ,
in which case, we add xi to a copy of the satellite data from Li−1 to make our
new set of elements to associate with the element in Li .
Problem 35-1
a. First, we will show that it is np hard to determine if, given a set of numbers,
there is a subset of them whose sum is equal to the sum of that set’s compli-
ment, this is called the partition problem. We will show this is NP hard by
using it to solve the subset sum problem. Suppose that we wanted to fund
a subset of {y1 , y2 , . . . yn } Pthat summed to t. Then, we will run partition
on the set {y1 , y2 , . . . , ynP
, ( i yi ) − 2t}. Note then, that the sum of all the
elements in this set is 2 ( i yi ) − 2t. So, any partition must have both sides
equal to half that. If there is a subset of the original set that sums to t, we
can put that on one side together with the element we add, and put all the
other original elements on the other side, giving us a partition. Suppose that
we had a partition, then all the elements that are on the same side as the
special added element form a subset that is equal to t. This show that the
partition problem is NP hard.
Let {x1 , x2 , . . . , xn } be an instance of the partition problem. Then, we will
construct an instance of a packing problem that can be packed into 2 bins if
and only if there is a subset of {x1 , x2 , . . . xn } with sum equal to that of its
compliment. To do this, we will just let our values be ci = Pn2xi xj . Then,
j=1
the total weight is exactly 2, so clearly two bins are needed. Also, it can fit
in two bins if there is a partition of the original set.
b. If we could pack the elements in to fewer than dSe bins, that means that the
total capacity from our bins is < bSc ≤ S, however, we know that to total
space needed to store the elements is S, so there is no way we could fit them
in less than that amount of space.
c. Suppose that there was already one bin that is at most half full, then when
we go to insert an element that has size at most half, it will not go into an
unused bin because it would be placed in this bin that is at most half full.
This means that we will never create a second bin that is at most half full,
and so, since we start off with fewer that two bins that are at most half full,
there will never be two bins that are at most half full (and so never two that
are less than half full).
d. Since there is at most one bin that is less than half full, we know that the
total amount of size that we have packed into our P bins is > 12 (P − 1). That
is, we know that S > 21 (P − 1), which tells us that 2S + 1 > P . So, if we were
12
to have P > d2Se, then, we have that P ≥ d2Se+1 = d2S +1e ≥ 2S +1 > P ,
which is a contradiction.
e. We know from part b that there is a minimum of dSe bins required. Also,
by part d, we know that the first fit heuristic causes us to sue at most d2Se
bins. This means that the number of bins we report is at most off by a factor
of d2Se
dSe ≤ 2.
f. We can implement the first fit heuristic by just keeping an array of bins, and
each time just doing a linear scan to find the first bin that can accept it.
So, if we let P be the number of bins, this procedure will have a runtime of
O(P 2 ) = O(n2 ). However, since all we needed was that there was at most
one bin that was less than half full, we could do a faster procedure. We keep
the array of bins as before, but we will keep track of the first empty bin and
a pointer to a bin that is less than half full. Upon insertion, if the thing we
inserted is more than half, put it in the first empty bin and increment it.
If it is less than half, it will fit in the bin that is less than half full, if that
bin then becomes more than half full, get rid of the less than half full bin
pointer. If there wasn’t a nonempty bin that was less than half full, we just
put the element in the first empty bin. This will run in time O(n) and still
satisfy everything we needed to assure we had a 2-approximation.
Problem 35-2
13
b. Suppose there is an approximation algorithm that has a constant approxi-
mation ratio c for finding a maximum size clique. Given G, form G(k) , where
k will be chosen shortly. Perform the approximation algorithm on G(k) . If n
is the maximum size clique of G(k) returned by the approximation algorithm
and m is the actual maximum size clique of G, then we have mk /n ≤ c. If
there is a clique of size at least n in G(k) , we know there is a clique of size
at least n1/k in G, and we have m/n1/k ≤ c1/k . Choosing k > 1/ logc (1 + ε),
this gives m/n1/k ≤ 1 + ε. Since we can form G(k) in time polynomial in k,
we just need to verify that k is a polynomial in 1/ε. To this end,
where the last inequality follows from (3.17). Thus, the (1+ε) approximation
algorithm is polynomial in the input size, and 1/ε, so it is a polynomial time
approximation scheme.
Problem 35-3
An obvious way to generalize the greedy set cover heuristic is to not just pick
the set that covers the most uncovered elements, but instead to repeatedly select
the set that maximizes the value of the number of uncovered points it covers
divided by its weight. This agrees with the original algorithm in the case that
the weights are all 1. The main difference is that instead of each step of the algo-
rithm assigning one unit of cost, it will be assigning wi units of cost to add the set
Si . So, suppose that C is the coverP we selected Pby this heuristic,
P andP C ∗ is an op-
timal cover.
P So, we will have
P | w
Si ∈C i | = w
x∈X i xc ≤ P Si ∈C ∗ x∈Si wi cx .
Then,
P w
x∈Si i xc = w i c
x∈Si x ≤ wi H(|S|). So, |C| ≤ Si ∈C ∗ wi H(|Si |) ≤
| Si ∈C ∗ wi |H(max(|Si |). This means that the weight of the selected cover is a
H(d) approximation for the weight of the optimal cover.
Problem 35-4
a. Let V = {a, b, c, d} and E = {{a, b}, {b, c}, {c, d}}. Then {b, c} is a maximal
matching, but a maximum matching consists of {a, b} and {c, d}.
b. The greedy algorithm considers each edge one at a time. If it can be added
to the matching, add it. Otherwise discard it and never consider it again.
If an edge can’t be added at some time, then it can’t be added at any later
time, so the result is a maximal matching. We can determine whether or not
to add an edge in constant time by creating an array of size |V | filled with
zeros, and placing a 1 in position i if the ith vertex is incident with an edge
in the matching. Thus, the runtime of the greedy algorithm is O(E).
c. Let M be a maximum matching. In any vertex cover C, each edge in M
must have the property that at least one of its endpoints is in C. Moreover,
no two edges in M have any endpoints in common, so the sice of C is at least
that of M .
14
d. It consists of only isolated vertices and no edges. If an edge {u, v} were
contained in the subgraph of G induced by the vertices of G not in T , then
this would imply that neither u nor v is incident on some edge in M , so
we could add the edge {u, v} to M and it would still be a matching. This
contradicts maximality.
e. We can construct a vertex cover by taking the endpoints of every edge in M .
This has size 2|M | because the endpoints of edges in a matching are disjoint.
Moreover, if any edge failed to be incident to any vertex in the cover, this
edge would be in the induced subgraph of G induced by the vertices which
are not in T . By part d, no such edge exists, so it is a vertex cover.
f. The greedy algorithm of part (b) yields a maximal matching M . By part
(e), there exists a vertex cover of size 2|M |. By part (c), the size of this
vertex cover exceeds the sizeof a maximum matching, so 2|M | is an upper
bound on the size of a maximum matching. Thus, the greedy algorithm is a
2|M |/|M | = 2 approximation algorithm.
Problem 35-5
a. Suppose that the greatest processing time is pi . Then, any schedule must
assign the job Ji to some processor. If it assigns Ji to start as soon as
possible, it still won’t finish until pi units have passed. This means that
since the makespan is the time that all jobs have finished, it will at or after
pi because it needs job Ji to of finished. This problem can be viewed as a
restatement of (27.3), where we have an infinite number of processors and
assign each job to its own processor.
b. The total amount of processing per step of time is one per processor. Since
1
P
we need to accomplish i pi much work, we have to of spent at lest m times
that amount of time. This problem is a restatement of equation (27.2).
c. See the algorithm GREEDY-SCHEDULE
Algorithm 5 GREEDY-SCHEDULE
for every i = 1, . . . , m, let fi = 0. We will be updating this to be the latest
time that we have any task running on processor i.
put all of the fi into a min heap, H
while There is an unassigned job Ji do
extract the min element of H, let it be fj
assign job Ji to processor Mj , to run from fj to fj + pi .
fj = fj + pi
add fj to H
end while
Since we can perform all of the heap operations in time O(lg(m)), and we
need to perform one for each of our jobs, the runtime is in O(n lg(m)).
15
d. This is Theorem 27.1 and Corollary 27.2.
Problem 35-6
a. Let V = {a, b, c, d} and E = {{a, b}, {b, c}, {c, d}, {b, d}} with edge weights
3, 1, 5, and 4 respectively. Then SG = {{a, b}, {c, d}, {b, d}} = TG .
b. Let V = {a, b, c, d} and E = {{a, b}, {b, c}, {c, d}}. Then SG = {{a, b}, {c, d}} =
6
{{a, b}, {b, c}, {c, d}} = TG .
c. Consider the greedy algorithm for a maximum weight spanning tree: Sort the
edges from largest to smallest weight, consider them one at a time in order,
and if the edge doesn’t introduce a cycle, add it to the tree. Suppose that
we don’t select some edge {u, v} which is of maximum weight for u. This
means that the edge must introduce a cycle, so there is some edge {w, u}
which is already included in the spanning tree. However, we add edges in
order of decreasing weight, so w(w, u) > w(u, v) because edge weights are
distinct. This contradicts the fact that {u, v} was of maximum weight. Thus
SG ⊆ TG .
d. Since the edge weights are distinct, a particular edge can be the maximum
edge weight for at most two vertices, so |SG | ≥ |V |/2. Therefore |TG \SG | ≤
|V |/2 ≤ |SG |. Since every edge in TG \SG is nonmaximal, each of these has
weight less than the weight of any edge in SG . Let m be the minimum weight
of an edge in SG . Then w(TG \SG ) ≤ m|SG |, so w(TG ) ≤ w(SG ) + m|SG | ≤
2w(SG ). Therefore w(TG )/2 ≤ w(SG ).
e. Let N (v) denote the neighbors of a vertex v. The following algorithm
APPROX-MAX-SPANNING produces a subset of edges of a minimum span-
ning tree by part (c), and is a 2-approximation algorithm by part (d).
Algorithm 6 APPROX-MAX-SPANNING-TREE(V, E)
1: T = ∅
2: for v ∈ V do
3: max = −∞
4: best = v
5: for u ∈ N (v) do
6: if w(v, u) ≥ max then
7: v=u
8: max = w(v, u)
9: end if
10: end for
11: T = T ∪ {v, u}
12: end for
13: return T
Problem 35-7
16
a. Though not stated, this conclusion requires the assumption that at least one
of the values is non-negative. Since any individual item will fit, selecting
that one item would be a solution that is better then the solution of taking
no items. We know then that the optimal solution contains at least one
item. Suppose the item of largest index that it contains is item i, then, that
solution would be in Pi , since the only restriction we placed when we changed
the instance to Ii was that it contained item i.
b. We clearly need to include all of item j, as that is a condition of instance
Ij . Then, since we know that we will be using up all of the remaining space
somehow, we want to use it up in such a way that the average value of that
space is maximized. This is clearly achieved by maximizing the value density
of all the items going in, since the final value density will be an average of
the value densities that went into it weighted by the amount of space that
was used up by items with that value density.
c. Since we are greedily selecting items based off of the amount of value per
space, we only stop once we can no longer fit any more, and each time before
putting some faction of the item with the next least value per space, we
complete putting in the item we currently are. This means that there is at
most one item fractionally.
d. First, it is trivial that v(Qj )/2 ≥ v(Pj )/2 since we are trying to maximize a
quantity, and there are strictly fewer restrictions on what we can do in the
case of the fractional packing than in the 1-0 packing. To see that v(Rj ) ≥
v(Qj )/2, note that among the items {1, 2, . . . , j}, we have the highest value
item is vj because of our ordering of the items. We know that the fractional
solution must have all of item j, and there is some item that it may not
have all of that is indexed by less than j. This part of an item is all that
is thrown out when going from Qj to Rj . Even if we threw all of that item
out, it still wouldn’t be as valuable as item j which we are keeping, so, we
have retained more than half of the value. So, we have proved the slightly
stronger statement that v(Rj ) > v(Qj )/2 ≥ v(Pj )/2.
e. Since we knew that the optimal solution was the max of all the Pj (part a),
and we know that each Pj is at most 2Rj (part d), by selecting the max of all
the the Rj , we are obtaining a solution that is at most a factor of two less
than the optimal solution.
17