Docsity

4 Solved Problems on Algorithm Design - Assignment 5 | ECS 122A, Assignments of Computer Science

Toggle sidebar
bg1
ECS 122A: Algorithm Design and Analysis Handout 1
UC Davis — Charles Martel Friday, March 7
Problem Set 5 solutions,
(25) Problem 1. Problem 4.2 in the text
The cuts can be computed either on the original graph (so only done once) or on the current
Connected Components (CC) (which may yield smaller cuts).
At most k−1 cuts, E1,E2. . . , Er, r < k are required (since each cut increases the number
of CC’s with a terminal by at least one). As in the original proof, we want to compare each
cut Eito a cut Ajand argue w(Ei)≤w(Aj).
The main idea is that if Eiis a min-cut for a, b, then it must be no larger than the best
isolating cut for aand for b(else we would use that cut). So w(Ei)≤MI N (w(Ca), , w(Cb)
(where Ca, Cbare optimal isolating cuts as used in algorithm 4.3). If we can map each Eito
aCjsuch that each Cjis used at most once, then we are done (the total cost of the E0
jsis at
most the cost of C0
is, the cost of alg. 4.3).
To get the desired mapping consider a tree of connected components representing the algo-
rithm as it runs: the root is a CC with all terminals. The first cut creates 2+ CC’s that are
the children of the root. The leaves of the tree are CC’s with a single terminal. If an internal
node in the tree is for a CC with rterminals, than there are rleaves below this node. Thus
we can associate the cut Eithat created this node with a leaf (terminal) that is below it and
thus was in the CC split by this cut. Since an isolating cut for that terminal was a possible
choice to split the CC, the cut Eichosen had equal or smaller weight. By construction, there
are enough leaves so each internal node can be mapped to a distinct leaf.
(25) Problem 2. Problem 4.4 in the text.
Let Tbe a maximum spanning tree for K. If (u, w1), . . . (wr, v ) is the unique path from uto
vin T, then we know the min-cut for (u, v) in Tis
f(u, v) = M IN{f(u, w1), f (w1, w2), . . . f(wr, v)}.
By 4.1 in the prior problem, we know
f(u, v)≥M IN{f(u, w1), f (w1, w2), . . . f(wr, v)}
This holds with equality (as desired) unless
(*) f(u, v)> M IN{f(u, w1), f (w1, w2), . . . f(wr, v)}.
However, (*) contradicts T being a maximum spanning tree. If (*) holds, (u, v) is not an edge
in T. However, we can add (u, v) to T, create a cycle with (u, w1), . . . (wr, v), the unique path
from uto vin T. But by (*) if we delete the cheapest edge in this cycle, we will get a less
costly spanning tree. Thus we must have:
f(u, v) = M IN{f(u, w1), f (w1, w2), . . . f(wr, v)}.
(25) Problem 3. Problem 9.6 in the text.
Let s1, . . . skbe the sizes of items in the kgroups of J(after rounding up) and s0
1, . . . s0
kbe
the sizes of items in the kgroups of J0(after rounding down). By construction, s0
i+1 ≥si.
Thus we can use the packing of items in group i+ 1 of J0to pack items of group iin J. This
works for each group except the biggest one in J(since there is no ’next’ group in J0to use).
Thus we get a packing for all expect the Q largest items in J.
pf2

Partial preview of the text

Download 4 Solved Problems on Algorithm Design - Assignment 5 | ECS 122A and more Assignments Computer Science in PDF only on Docsity!

ECS 122A: Algorithm Design and Analysis Handout 1 UC Davis — Charles Martel Friday, March 7

Problem Set 5 solutions,

(25) Problem 1. Problem 4.2 in the text

The cuts can be computed either on the original graph (so only done once) or on the current Connected Components (CC) (which may yield smaller cuts). At most k − 1 cuts, E 1 , E 2... , Er, r < k are required (since each cut increases the number of CC’s with a terminal by at least one). As in the original proof, we want to compare each cut Ei to a cut Aj and argue w(Ei) ≤ w(Aj ). The main idea is that if Ei is a min-cut for a, b, then it must be no larger than the best isolating cut for a and for b (else we would use that cut). So w(Ei) ≤ M IN (w(Ca), , w(Cb) (where Ca, Cb are optimal isolating cuts as used in algorithm 4.3). If we can map each Ei to a Cj such that each Cj is used at most once, then we are done (the total cost of the E′ j s is at most the cost of C i′s, the cost of alg. 4.3). To get the desired mapping consider a tree of connected components representing the algo- rithm as it runs: the root is a CC with all terminals. The first cut creates 2+ CC’s that are the children of the root. The leaves of the tree are CC’s with a single terminal. If an internal node in the tree is for a CC with r terminals, than there are r leaves below this node. Thus we can associate the cut Ei that created this node with a leaf (terminal) that is below it and thus was in the CC split by this cut. Since an isolating cut for that terminal was a possible choice to split the CC, the cut Ei chosen had equal or smaller weight. By construction, there are enough leaves so each internal node can be mapped to a distinct leaf.

(25) Problem 2. Problem 4.4 in the text.

Let T be a maximum spanning tree for K. If (u, w 1 ),... (wr, v) is the unique path from u to v in T, then we know the min-cut for (u, v) in T is f (u, v) = M IN {f (u, w 1 ), f (w 1 , w 2 ),... f (wr, v)}. By 4.1 in the prior problem, we know f (u, v) ≥ M IN {f (u, w 1 ), f (w 1 , w 2 ),... f (wr, v)} This holds with equality (as desired) unless () f (u, v) > M IN {f (u, w 1 ), f (w 1 , w 2 ),... f (wr, v)}. However, () contradicts T being a maximum spanning tree. If () holds, (u, v) is not an edge in T. However, we can add (u, v) to T, create a cycle with (u, w 1 ),... (wr, v), the unique path from u to v in T. But by () if we delete the cheapest edge in this cycle, we will get a less costly spanning tree. Thus we must have: f (u, v) = M IN {f (u, w 1 ), f (w 1 , w 2 ),... f (wr, v)}.

(25) Problem 3. Problem 9.6 in the text.

Let s 1 ,... sk be the sizes of items in the k groups of J (after rounding up) and s′ 1 ,... s′ k be the sizes of items in the k groups of J′^ (after rounding down). By construction, s′ i+1 ≥ si. Thus we can use the packing of items in group i + 1 of J′^ to pack items of group i in J. This works for each group except the biggest one in J (since there is no ’next’ group in J′^ to use). Thus we get a packing for all expect the Q largest items in J.

2 ECS 122A Handout 1: Problem Set 5 solutions,

(25) Problem 4. Consider the online version of bin-packing where we have pack item i before we see the remaining items. In addition, we don’t know how many items we need to pack until we see them (e.g. we must pack items a 1 ,... ak without knowing if there are additional items, or what they are). a. Consider the following two possible lists of items to pack: L 1 = (. 4 ,. 4 ,... , .4) with k items. L 2 = L 1 , (. 6 ,. 6 ,... , .6) with k items in the second part of the list. Use these two lists to prove that no online algorithm can pack all lists using fewer than 4/3 OPT bins (note this is not a bound on computing time, even if the algorithm is allowed infinite time to find the best packing it can’t without knowledge of future items). OPT(L 1 ) = k/2. Thus to packL 1 with an error less than 4/3 we must pack the items using b 1 < 4 / 3 × k/2 = k(2/3) bins. Let T be the number of bins with Two items and S the number of bins with a single item (for L 1 ). Thus we must have T > k/3 bins and S < k/3. From this start (for L 1 ), we then need T + k − S bins to pack L 2. If T > k/3 bins and S < k/3, we use b 2 > (4/3)k bins for L 2 , so b 2 /k > 4 /3 which contracts b 2 /OP T (L 2 ) ≤ 4 /3. b. Construct an alternate collection of lists to pack to show a better bound than 4/3 for online bin- packing (it’s known that no online algorithm can achieve a bound of 3/2 of OPT, but you can try for something in between 4/3 and 3/2). Now use 3 lists

L 1 = (. 15 ,. 15 ,... , .15) with k items. L 2 = L 1 (. 34 ,. 34 ,... , .34) with k items in the last part of the list. L 3 = L 2 , (. 51 ,. 51 ,... , .51) with k items in the last part of the list. Using the fact that OPT(L 1 ) = k/6, OPT(L 2 = k/2), and OPT(L 3 = k) we can show that no algorithm uses less than 3/2 OPT(L) bins for all lists L (considering we need to keep many single items from L 2 to pair with items in the end of L 3 , but then we can’t pack the first two lists well).