Docsity

Approximation Algorithms, Load Balancing - Notes | CS 573, Study notes of Algorithms and Programming

Toggle sidebar
bg1
Algorithms Lecture 8: Approximation Algorithms
Le mieux est l’ennemi du bien. [The best is the enemy of the good.]
— Voltaire, La Bégueule (1772)
Who shall forbid a wise skepticism, seeing that there is no practical question
on which any thing more than an approximate solution can be had?
— Ralph Waldo Emerson, Representative Men (1850)
Now, distrust of corporations threatens our still-tentative economic recovery;
it turns out greed is bad, after all.
— Paul Krugman, “Greed is Bad”, The New York Times, June 4, 2002.
8 Approximation Algorithms
8.1 Load Balancing
On the future smash hit reality-TV game show Grunt Work, scheduled to air Thursday nights at 3am
(2am Central) on ESPN
π
, the contestants are given a series of utterly pointless tasks to perform. Each
task has a predetermined time limit; for example, “Sharpen this pencil for 17 seconds”, or “Pour pig’s
blood on your head and sing The Star-Spangled Banner for two minutes”, or “Listen to this 75-minute
algorithms lecture”. The directors of the show want you to assign each task to one of the contestants,
so that the last task is completed as early as possible. When your predecessor correctly informed the
directors that their problem is NP-hard, he was immediately fired. “Time is money!” they screamed at
him. “We don’t need perfection. Wake up, dude, this is television!”
Less facetiously, suppose we have a set of
n
jobs, which we want to assign to
m
machines. We are
given an array
T
[1
.. n
]of non-negative numbers, where
T
[
j
]is the running time of job
j
. We can
describe an assignment by an array
A
[1
.. n
], where
A
[
j
] =
i
means that job
j
is assigned to machine
i
.
The makespan of an assignment is the maximum time that any machine is busy:
makespan(A) = max
iX
A[j]=i
T[j]
The load balancing problem is to compute the assignment with the smallest possible makespan.
It’s not hard to prove that the load balancing problem is NP-hard by reduction from PARTITION: The
array
T
[1
.. n
]can be evenly partitioned if and only if there is an assignment to two machines with
makespan exactly
PiT
[
i
]
/
2. A slightly more complicated reduction from 3PARTITION implies that the
load balancing problem is strongly NP-hard. If we really need the optimal solution, there is a dynamic
programming algorithm that runs in time
O
(
nM m
), where
M
is the minimum makespan, but that’s just
horrible.
There is a fairly natural and efficient greedy heuristic for load balancing: consider the jobs one at a
time, and assign each job to the machine with the earliest finishing time.
GREE DYLOA DBALANCE(T[1.. n],m):
for i←1 to m
Total[i]←0
for j←1 to n
min ←1
for i←2 to n
if Total[i]<Total[min]
min ←i
A[j]←min
Total[mi n]←Total[min] + T[j]
return A[1.. m]
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Approximation Algorithms, Load Balancing - Notes | CS 573 and more Study notes Algorithms and Programming in PDF only on Docsity!

Le mieux est l’ennemi du bien. [The best is the enemy of the good.] — Voltaire, La Bégueule (1772) Who shall forbid a wise skepticism, seeing that there is no practical question on which any thing more than an approximate solution can be had? — Ralph Waldo Emerson, Representative Men (1850) Now, distrust of corporations threatens our still-tentative economic recovery; it turns out greed is bad, after all. — Paul Krugman, “Greed is Bad”, The New York Times , June 4, 2002.

8 Approximation Algorithms

8.1 Load Balancing

On the future smash hit reality-TV game show Grunt Work , scheduled to air Thursday nights at 3am (2am Central) on ESPN π , the contestants are given a series of utterly pointless tasks to perform. Each task has a predetermined time limit; for example, “Sharpen this pencil for 17 seconds”, or “Pour pig’s blood on your head and sing The Star-Spangled Banner for two minutes”, or “Listen to this 75-minute algorithms lecture”. The directors of the show want you to assign each task to one of the contestants, so that the last task is completed as early as possible. When your predecessor correctly informed the directors that their problem is NP-hard, he was immediately fired. “Time is money!” they screamed at him. “We don’t need perfection. Wake up, dude, this is television !” Less facetiously, suppose we have a set of n jobs, which we want to assign to m machines. We are given an array T [ 1 .. n ] of non-negative numbers, where T [ j ] is the running time of job j. We can describe an assignment by an array A [ 1 .. n ], where A [ j ] = i means that job j is assigned to machine i. The makespan of an assignment is the maximum time that any machine is busy:

makespan ( A ) = max i

A [ j ]= i

T [ j ]

The load balancing problem is to compute the assignment with the smallest possible makespan. It’s not hard to prove that the load balancing problem is NP-hard by reduction from PARTITION: The array T [ 1 .. n ] can be evenly partitioned if and only if there is an assignment to two machines with makespan exactly

i T^ [ i ] / 2. A slightly more complicated reduction from 3PARTITION^ implies that the load balancing problem is strongly NP-hard. If we really need the optimal solution, there is a dynamic programming algorithm that runs in time O ( nM m ), where M is the minimum makespan, but that’s just horrible. There is a fairly natural and efficient greedy heuristic for load balancing: consider the jobs one at a time, and assign each job to the machine with the earliest finishing time. GREEDYLOADBALANCE( T [1 .. n ], m ): for i ← 1 to m Total [ i ] ← 0 for j ← 1 to n min ← 1 for i ← 2 to n if Total [ i ] < Total [ min ] min ← i A [ j ] ← min Total [ min ] ← Total [ min ] + T [ j ] return A [1 .. m ]

Theorem 1. The makespan of the assignment computed by GREEDYLOADBALANCE is at most twice the makespan of the optimal assignment.

Proof: Fix an arbitrary input, and let OP T denote the makespan of its optimal assignment. The approximation bound follows from two trivial observations. First, the makespan of any assignment (and therefore of the optimal assignment) is at least the duration of the longest job. Second, the makespan of any assignment is at least the total duration of all the jobs divided by the number of machines.

OP T ≥ max j T [ j ] and OP T ≥

m

∑^ n

j = 1

T [ j ]

Now consider the assignment computed by GREEDYLOADBALANCE. Suppose machine i has the largest total running time, and let j be the last job assigned to job i. Our first trivial observation implies that T [ j ] ≤ OP T. To finish the proof, we must show that Total [ i ] − T [ j ] ≤ OP T. Job j was assigned to machine i because it had the smallest finishing time, so Total [ i ] − T [ j ] ≤ Total [ k ] for all k. (Some values Total [ k ] may have increased since job j was assigned, but that only helps us.) In particular, Total [ i ] − T [ j ] is less than or equal to the average finishing time over all machines. Thus,

Total [ i ] − T [ j ] ≤

m

∑^ m

i = 1

Total [ i ] =

m

∑^ n

j = 1

T [ j ] ≤ OP T

by our second trivial observation. We conclude that the makespan Total [ i ] is at most 2 · OP T. É

j ≤ OPT

≤ OPT

i

makespan

Proof that GreedyLoadBalance is a 2-approximation algorithm

GREEDYLOADBALANCE is an online algorithm: It assigns jobs to machines in the order that the jobs appear in the input array. Online approximation algorithms are useful in settings where inputs arrive in a stream of unknown length—for example, real jobs arriving at a real scheduling algorithm. In this online setting, it may be impossible to compute an optimum solution, even in cases where the offline problem (where all inputs are known in advance) can be solved in polynomial time. The study of online algorithms could easily fill an entire one-semester course (alas, not this one). In our original offline setting, we can improve the approximation factor by sorting the jobs before piping them through the greedy algorithm.

SORTEDGREEDYLOADBALANCE( T [1 .. n ], m ): sort T in decreasing order return GREEDYLOADBALANCE( T , m )

Theorem 2. The makespan of the assignment computed by SORTEDGREEDYLOADBALANCE is at most 3 / 2 times the makespan of the optimal assignment.

Obviously this algorithm doesn’t compute the optimal vertex cover—that would imply P=NP!—but it does compute a reasonably close approximation.

Theorem 3. GREEDYVERTEXCOVER is an O (log n )-approximation algorithm.

Proof: For all i , let Gi denote the graph G after i iterations of the main loop, and let di denote the maximum degree of any node in Gi − 1. We can define these variables more directly by adding a few extra lines to our algorithm:

GREEDYVERTEXCOVER( G ): C ← ∅ G 0 ← G i ← 0 while Gi has at least one edge i ← i + 1 vi ← vertex in Gi − 1 with maximum degree di ← deg Gi − 1 ( vi ) Gi ← Gi − 1 \ vi C ← C ∪ vi return C

Let | Gi − 1 | denote the number of edges in the graph Gi − 1. Let C ∗^ denote the optimal vertex cover of G , which consists of OP T vertices. Since C ∗^ is also a vertex cover for Gi − 1 , we have ∑

v ∈ C ∗

deg Gi − 1 ( v ) ≥ | Gi − 1 |.

In other words, the average degree in Gi of any node in C ∗^ is at least | Gi − 1 | /OP T. It follows that Gi − 1 has at least one node with degree at least | Gi − 1 | /OP T. Since di is the maximum degree of any node in Gi − 1 , we have

di ≥

| Gi − 1 | OP T

Moreover, for any j ≥ i − 1, the subgraph Gj has no more edges than Gi − 1 , so di ≥ | Gj | /OP T. This observation implies that

OP T ∑

i = 1

di ≥

OP T ∑

i = 1

| Gi − 1 | OP T

OP T ∑

i = 1

| GOP T |

OP T

= | GOP T | = | G | −

OP T ∑

i = 1

di.

In other words, the first OP T iterations of GREEDYVERTEXCOVER remove at least half the edges of G. Thus, after at most OP T lg| G | ≤ 2 OP T lg n iterations, all the edges of G have been removed, and the algorithm terminates. We conclude that GREEDYVERTEXCOVER computes a vertex cover of size O ( OP T log n ). É

So far we’ve only proved an upper bound on the approximation factor of GREEDYVERTEXCOVER; perhaps a more careful analysis would imply that the approximation factor is only O (log log n ), or even O ( 1 ). Alas, no such improvement is possible. For any integer n , a simple recursive construction gives us an n -vertex graph for which the greedy algorithm returns a vertex cover of size Ω( OP T · log n ). Details are left as an exercise for the reader.

8.4 Set Cover and Hitting Set

The greedy algorithm for vertex cover can be applied almost immediately to two more general problems:

set cover and hitting set. The input for both of these problems is a set system ( X , F), where X is a finite

ground set , and F is a family of subsets of X.^2 A set cover of a set system ( X , F) is a subfamily of sets in

F whose union is the entire ground set X. A hitting set for ( X , F) is a subset of the ground set X that

intersects every set in F.

An undirected graph can be cast as a set system in two different ways. In one formulation, the

ground set X contains the vertices, and each edge defines a set of two vertices in F. In this formulation,

a vertex cover is a hitting set. In the other formulation, the edges are the ground set, the vertices define the family of subsets, and a vertex cover is a set cover. Here are the natural greedy algorithms for finding a small set cover and finding a small hitting set.

GREEDYSETCOVER finds a set cover whose size is at most O (log |F|) times the size of smallest set cover.

GREEDYHITTINGSET finds a hitting set whose size is at most O (log | X |) times the size of the smallest hitting set.

GREEDYSETCOVER( X , F): C ← ∅ while X 6 = ∅ S ← arg max S ∈F

| S ∩ X |

X ← X \ S

C ← C ∪ { S }

return C

GREEDYHITTINGSET( X , F):

H ← ∅

while F 6 = ∅ x ← arg max x ∈ X

|{ S ∈ F | x ∈ S }| F ← F \ { S ∈ F | x ∈ S } H ← H ∪ { x } return H

The similarity between these two algorithms is no coincidence. For any set system ( X , F), there is a

dual set system (F, X ∗) defined as follows. For any element x ∈ X in the ground set, let x ∗^ denote the

subfamily of sets in F that contain x :

x ∗^ = { S ∈ F | x ∈ S }.

Finally, let X ∗^ denote the collection of all subsets of the form x ∗:

X ∗^ =

x ∗^ x ∈ S

As an example, suppose X is the set of letters of alphabet and F is the set of last names of student taking

CS 573 this semester. Then X ∗^ has 26 elements, each containing the subset of CS 573 students whose

last name contains a particular letter of the alphabet. For example, m∗^ is the set of students whose last

names contain the letter m. There is a direct one-to-one correspondence between the ground set X and the dual set family X ∗. It is a tedious but instructive exercise to prove that the dual of the dual of any set system is isomorphic to

the original set system—( X ∗, F∗) is essentially the same as ( X , F). It is also easy to prove that a set cover

for any set system ( X , F) is also a hitting set for the dual set system (F, X ∗), and therefore a hitting set

for any set system ( X , F) is isomorphic to a set cover for the dual set system (F, X ∗).

8.5 Vertex Cover, Again

The greedy approach doesn’t always lead to the best approximation algorithms. Consider the following alternate heuristic for vertex cover: (^2) A matroid (see the lecture note on greedy algorithms) is a special type of set system.

8.7 Traveling Salesman: The Good News

Even though the general traveling salesman problem can’t be approximated, a common special case can be approximated fairly easily. The special case requires the edge lengths to satisfy the so-called triangle inequality : _ ( _u_ , _w_ ) ≤ _ ( u , v ) + ` ( v , w ) for any vertices u , v , w.

This inequality is satisfied for geometric graphs , where the vertices are points in the plane (or some higher-dimensional space), edges are straight line segments, and lengths are measured in the usual Euclidean metric. Notice that the length functions we used above to show that the general TSP is hard to approximate do not (always) satisfy the triangle inequality. With the triangle inequality in place, we can quickly compute a 2-approximation for the traveling salesman tour as follows. First, we compute the minimum spanning tree T of the weighted input graph; this can be done in O ( n^2 log n ) time (where n is the number of vertices of the graph) using any of several classical algorithms. Second, we perform a depth-first traversal of T , numbering the vertices in the order that we first encounter them. Because T is a spanning tree, every vertex is numbered. Finally, we return the cycle obtained by visiting the vertices according to this numbering.

6

7 5

2 3

4

1

6

7 5

2 4

3

1

A minimum spanning tree T , a depth-first traversal of T , and the resulting approximate traveling salesman tour.

Let OP T denote the cost of the optimal TSP tour, let M ST denote the total length of the minimum spanning tree, and let A be the length of the tour computed by our approximation algorithm. Consider the ‘tour’ obtained by walking through the minimum spanning tree in depth-first order. Since this tour traverses every edge in the tree exactly twice, its length is 2 · M ST. The final tour can be obtained from this one by removing duplicate vertices, moving directly from each node to the next unvisited node.; the triangle inequality implies that taking these shortcuts cannot make the tour longer. Thus, A ≤ 2 · M ST. On the other hand, if we remove any edge from the optimal tour, we obtain a spanning tree (in fact a spanning path ) of the graph; thus, M ST ≥ OP T. We conclude that A ≤ 2 · OP T ; our algorithm computes a 2-approximation of the optimal tour. We can improve this approximation factor using the following algorithm discovered by Nicos Christofides in 1976. As in the previous algorithm, we start by constructing the minimum spanning tree T. Then let O be the set of vertices with odd degree in T ; it is an easy exercise (hint, hint) to show that the number of vertices in O is even. In the next stage of the algorithm, we compute a minimum-cost perfect matching M of these odd- degree vertices. A prefect matching is a collection of edges, where each edge has both endpoints in O and each vertex in O is adjacent to exactly one edge; we want the perfect matching of minimum total length. Later in the semester, we will see an algorithm to compute M in polynomial time. Now consider the multigraph T ∪ M ; any edge in both T and M appears twice in this multigraph. This graph is connected, and every vertex has even degree. Thus, it contains an Eulerian circuit : a closed walk that uses every edge exactly once. We can compute such a walk in O ( n ) time with a simple modification of depth-first search. To obtain the final approximate TSP tour, we number the vertices in

the order they first appear in some Eulerian circuit of T ∪ M , and return the cycle obtained by visiting the vertices according to that numbering.

7

6 5

2 4

3

1

7

6 5

2 4

3

1

A minimum spanning tree T , a minimum-cost perfect matching M of the odd vertices in T , an Eulerian circuit of T ∪ M , and the resulting approximate traveling salesman tour.

Theorem 5. Given a weighted graph that obeys the triangle inequality, the Christofides heuristic computes a (3/2)-approximation of the minimum traveling salesman tour.

Proof: Let A denote the length of the tour computed by the Christofides heuristic; let OP T denote the length of the optimal tour; let M ST denote the total length of the minimum spanning tree; let M OM denote the total length of the minimum odd-vertex matching. The graph T ∪ M , and therefore any Euler tour of T ∪ M , has total length M ST + M OM. By the triangle inequality, taking a shortcut past a previously visited vertex can only shorten the tour. Thus, A ≤ M ST + M OM. By the triangle inequality, the optimal tour of the odd-degree vertices of T cannot be longer than OP T. Any cycle passing through of the odd vertices can be partitioned into two perfect matchings, by alternately coloring the edges of the cycle red and green. One of these two matchings has length at most OP T / 2. On the other hand, both matchings have length at least M OM. Thus, M OM ≤ OP T / 2. Finally, recall our earlier observation that M ST ≤ OP T. Putting these three inequalities together, we conclude that A ≤ 3 · OP T / 2, as claimed. É

8.8 k -center Clustering

The k -center clustering problem is defined as follows. We are given a set P = { p 1 , p 2 ,... , pn } of n points in the plane^4 and an integer k. Our goal to find a collection of k circles that collectively enclose all the input points, such that the radius of the largest circle is as large as possible. More formally, we want to compute a set C = { c 1 , c 2 ,... , ck } of k center points , such that the following cost function is minimized:

cost ( C ) := max i min j | pi cj |.

Here, | pi cj | denotes the Euclidean distance between input point pi and center point cj. Intuitively, each input point is assigned to its closest center point; the points assigned to a given center cj comprise a cluster. The distance from cj to the farthest point in its cluster is the radius of that cluster; the cluster is contained in a circle of this radius centered at cj. The k -center clustering cost cost ( C ) is precisely the maximum cluster radius. This problem turns out to be NP-hard, even to approximate within a factor of roughly 1. 8. However, there is a natural greedy strategy, first analyzed in 1985 by Teofilo Gonzalez^5 , that is guaranteed to (^4) Actually, the k -center problem can be defined over any metric space; the approximation analysis in this section holds in any metric space as well. The analysis in the next section, however, does require that the points come from the Euclidean plane. (^5) Teofilo F. Gonzalez. Clustering to minimize the maximum inter-cluster distance. Theoretical Computer Science 38:293-306,

output for that instance. As I mentioned earlier, computing even a 1 .8-approximation is NP-hard, so we cannot expect our approximation scheme to run in polynomial time; nevertheless, at least for small values of k , the approximation scheme will be considerably more efficient than any exact algorithm. Our approximation scheme works in three phases:

  1. Compute a 2-approximate clustering of the input set P using GONZALEZKCENTER. Let r be the cost of this clustering.
  2. Create a regular grid of squares of width δ = "r/ 2

p

  1. Let Q be a subset of P containing one point from each non-empty cell of this grid.

  2. Compute an optimal set of k centers for Q. Return these k centers as the approximate k -center clustering for P.

The first phase requires O ( nk ) time. By our earlier analysis, we have r ∗^ ≤ r ≤ 2 r ∗, where r ∗^ is the optimal k -center clustering cost for P. The second phase can be implemented in O ( n ) time using a hash table, or in O ( n log n ) time by standard sorting, by associating approximate coordinates (b x/δ c, b y/δ c) to each point ( x , y ) ∈ P and removing duplicates. The key observation is that the resulting point set Q is significantly smaller than P. We know P can be covered by k balls of radius r ∗, each of which touches O ( r ∗ /δ^2 ) = O ( 1 /"^2 ) grid cells. It follows that | Q | = O ( k/"^2 ). Let T ( n , k ) be the running time of an exact k -center clustering algorithm, given n points as input. If this were a computational geometry class, we might see a “brute force” algorithm that runs in time T ( n , k ) = O ( nk +^2 ); the fastest algorithm currently known^7 runs in time T ( n , k ) = nO (

p k ). If we use this

algorithm, our third phase requires ( k/"^2 ) O (

p k ) (^) time. It remains to show that the optimal clustering for Q implies a ( 1 + " )-approximation of the optimal clustering for P. Suppose the optimal clustering of Q consists of k balls B 1 , B 2 ,... , Bk , each of radius ˜ r. Clearly ˜ r ≤ r ∗, since any set of k balls that cover P also cover any subset of P. Each point in P \ Q shares a grid cell with some point in Q , and therefore is within distance δ

p 2 of some point in Q. Thus, if we increase the radius of each ball Bi by δ

p 2 , the expanded balls must contain every point in P. We conclude that the optimal centers for Q gives us a k -center clustering for P of cost at most r ∗^ + δ

p 2 ≤ r ∗^ + "r/ 2 ≤ r ∗^ + "r ∗^ = ( 1 + " ) r ∗. The total running time of the approximation scheme is O ( nk + ( k/"^2 ) O (

p k )). This is still exponential

in the input size if k is large (say

p n or n/ 100), but if k and " are fixed constants, the running time is linear in the number of input points.

8.10 An FPTAS for Subset Sum

An approximation scheme whose running time, for any fixed " , is polynomial in n is called a polynomial- time approximation scheme or PTAS (usually pronounced “pee taz"). If in addition the running time depends only polynomially on " , the algorithm is called a fully polynomial-time approximation scheme or FPTAS (usually pronounced “eff pee taz"). For example, an approximation scheme with running time O ( n^2 /"^2 ) is an FPTAS; an approximation scheme with running time O ( n^1 /" 6 ) is a PTAS but not an FPTAS; and our approximation scheme for k -center clustering is not a PTAS. The last problem we’ll consider is the SUBSETSUM problem: Given a set X containing n positive integers and a target integer t , determine whether X has a subset whose elements sum to t. The lecture notes on NP-completeness include a proof that SUBSETSUM is NP-hard. As stated, this problem doesn’t

(^7) R. Z. Hwang, R. C. T. Lee, and R. C. Chan. The slab dividing approach to solve the Euclidean p -center problem. Algorithmica 9(1):1–22, 1993.

allow any sort of approximation—the answer is either TRUE or FALSE.^8 So we will consider a related optimization problem instead: Given set X and integer t , find the subset of X whose sum is as large as possible but no larger than t. We have already seen a dynamic programming algorithm to solve the decision version SUBSETSUM in time O ( nt ); a similar algorithm solves the optimization version in the same time bound. Here is a different algorithm, whose running time does not depend on t :

SUBSETSUM( X [1 .. n ], t ): S 0 ← { 0 } for i ← 1 to n Si ← Si − 1 ∪ ( Si − 1 + X [ i ]) remove all elements of Si bigger than t return max Sn

Here Si − 1 + X [ i ] denotes the set { s + X [ i ] | s ∈ Si − 1 }. If we store each Si in a sorted array, the i th iteration of the for-loop requires time O (| Si − 1 |). Each set Si contains all possible subset sums for the first i elements of X ; thus, Si has at most 2 i^ elements. On the other hand, since every element of Si is an integer between 0 and t , we also have | Si | ≤ t + 1. It follows that the total running time of this algorithm is

∑ n i = 1 O (| Si −^1 |) =^ O (min{^2 n , nt }). Of course, this is only an estimate of worst-case behavior. If several subsets of X have the same sum, the sets Si will have fewer elements, and the algorithm will be faster. The key idea for finding an approximate solution quickly is to ‘merge’ nearby elements of Si —if two subset sums are nearly equal, ignore one of them. On the one hand, merging similar subset sums will introduce some error into the output, but hopefully not too much. On the other hand, by reducing the size of the set of sums we need to maintain, we will make the algorithm faster, hopefully significantly so. Here is our approximation algorithm. We make only two changes to the exact algorithm: an initial sorting phase and an extra FILTERing step inside the main loop.

FILTER( Z [1 .. k ], δ ): SORT( Z ) j ← 1 Y [ j ] ← Z [ i ] for i ← 2 to k if Z [ i ] > ( 1 + δ ) · Y [ j ] j ← j + 1 Y [ j ] ← Z [ i ] return Y [1 .. j ]

APPROXSUBSETSUM( X [1 .. n ], k , " ): SORT( X ) R 0 ← { 0 } for i ← 1 to n Ri ← Ri − 1 ∪ ( Ri − 1 + X [ i ]) Ri ← FILTER( Ri , "/ 2 n ) remove all elements of Ri bigger than t return max Rn

Theorem 7. APPROXSUBSETSUM returns a ( 1 + " )-approximation of the optimal subset sum, given any " such that 0 < " ≤ 1.

Proof: The theorem follows from the following claim, which we prove by induction:

For any element s ∈ Si , there is an element r ∈ Ri such that r ≤ s ≤ r · ( 1 + "n/ 2 ) i^.

The claim is trivial for i = 0. Let s be an arbitrary element of Si , for some i > 0. There are two cases to consider: either x ∈ Si − 1 , or x ∈ Si − 1 + xi.

(^8) Do, or do not. There is no ‘try’. (Are old one thousand when years you, alphabetical also in order talk will you.)

Exercises

  1. (a) Prove that for any set of jobs, the makespan of the greedy assignment is at most ( 2 − 1 /m ) times the makespan of the optimal assignment, where m is the number of machines. (b) Describe a set of jobs such that the makespan of the greedy assignment is exactly ( 2 − 1 /m ) times the makespan of the optimal assignment, where m is the number of machines. (c) Describe an efficient algorithm to solve the minimum makespan scheduling problem exactly if every processing time T [ i ] is a power of two.
  2. (a) Find the smallest graph (minimum number of edges) for which GREEDYVERTEXCOVER does not return the smallest vertex cover. (b) For any integer n , describe an n -vertex graph for which GREEDYVERTEXCOVER returns a vertex cover of size OP T · Ω(log n ).
  3. (a) Find the smallest graph (minimum number of edges) for which DUMBVERTEXCOVER does not return the smallest vertex cover. (b) Describe an infinite family of graphs for which DUMBVERTEXCOVER returns a vertex cover of size 2 · OP T.
  4. Consider the following heuristic for constructing a vertex cover of a connected graph G : return the set of non-leaf nodes in any depth-first spanning tree of G.

(a) Prove that this heuristic returns a vertex cover of G. (b) Prove that this heuristic returns a 2-approximation to the minimum vertex cover of G. (c) Describe an infinite family of graphs for which this heuristic returns a vertex cover of size 2 · OP T.

  1. Consider the following optimization version of the PARTITION problem. Given a set X of positive integers, our task is to partition X into disjoint subsets A and B such that max{

A ,

B } is as small as possible. This problem is clearly NP-hard. Determine the approximation ratio of the following polynomial-time approximation algorithm. Prove your answer is correct.

PARTITION( X [1 .. n ]): Sort X in increasing order a ← 0; b ← 0 for i ← 1 to n if a < b a ← a + X [ i ] else b ← b + X [ i ] return max{ a , b }

  1. The chromatic number χ ( G ) of a graph G is the minimum number of colors required to color the vertices of the graph, so that every edge has endpoints with different colors. Computing the chromatic number exactly is NP-hard.

Prove that the following problem is also NP-hard: Given an n -vertex graph G , return any integer between χ ( G ) and χ ( G ) + 573. [Note: This does not contradict the possibility of a constant factor approximation algorithm.]

  1. Let G = ( V , E ) be an undirected graph, each of whose vertices is colored either red, green, or blue. An edge in G is boring if its endpoints have the same color, and interesting if its endpoints have different colors. The most interesting 3-coloring is the 3-coloring with the maximum number of interesting edges, or equivalently, with the fewest boring edges. Computing the most interesting 3-coloring is NP-hard, because the standard 3-coloring problem is a special case.

(a) Let zzz ( G ) denote the number of boring edges in the most interesting 3-coloring of a graph G. Prove that it is NP-hard to approximate zzz ( G ) within a factor of 10^10

100 . (b) Let wow ( G ) denote the number of interesting edges in the most interesting 3-coloring of G. Suppose we assign each vertex in G a random color from the set {red, green, blue}. Prove that the expected number of interesting edges is at least 23 wow ( G ).

  1. Consider the following algorithm for coloring a graph G.

TREECOLOR( G ): T ← any spanning tree of G Color the tree T with two colors c ← 2 for each edge ( u , v ) ∈ G \ T T ← T ∪ {( u , v )} if color ( u ) = color ( v ) 〈〈 Try recoloring u with an existing color 〉〉 for i ← 1 to c if no neighbor of u in T has color i color ( u ) ← i if color ( u ) = color ( v ) 〈〈 Try recoloring v with an existing color 〉〉 for i ← 1 to c if no neighbor of v in T has color i color ( v ) ← i if color ( u ) = color ( v ) 〈〈 Give up and create a new color 〉〉 c ← c + 1 color ( u ) ← c

(a) Prove that this algorithm colors any bipartite graph with just two colors. (b) Let ∆( G ) denote the maximum degree of any vertex in G. Prove that this algorithm colors any graph G with at most ∆( G ) colors. This trivially implies that TREECOLOR is a ∆( G )- approximation algorithm. (c) Prove that TREECOLOR is not a constant-factor approximation algorithm.

  1. The KNAPSACK problem can be defined as follows. We are given a finite set of elements X where each element x ∈ X has a non-negative size and a non-negative value , along with an integer capacity c. Our task is to determine the maximum total value among all subsets of X whose total size is at most c. This problem is NP-hard. Specifically, the optimization version of SUBSETSUM is a special case, where each element’s value is equal to its size.

(a) Describe an efficient ( 1 − 1 /k )-approximation algorithm for this problem. (b) Now suppose we wish to minimize the sum of the weights of edges that do not cross the partition. What approximation ratio does your algorithm from part (a) achieve for the new problem? Justify your answer.

  1. The lecture notes describe a ( 3 / 2 )-approximation algorithm for the metric traveling salesman problem. Here, we consider computing minimum-cost Hamiltonian paths. Our input consists of a graph G whose edges have weights that satisfy the triangle inequality. Depending upon the problem, we are also given zero, one, or two endpoints.

(a) If our input includes zero endpoints, describe a ( 3 / 2 )-approximation to the problem of computing a minimum cost Hamiltonian path. (b) If our input includes one endpoint u , describe a ( 3 / 2 )-approximation to the problem of computing a minimum cost Hamiltonian path that starts at u. (c) If our input includes two endpoints u and v , describe a ( 5 / 3 )-approximation to the problem of computing a minimum cost Hamiltonian path that starts at u and ends at v.

  1. Suppose we are given a collection of n jobs to execute on a machine containing a row of m processors. When the i th job is executed, it occupies a contiguous set of prox [ i ] processors for time [ i ] seconds. A schedule for a set of jobs assigns each job an interval of processors and a starting time, so that no processor works on more than one job at any time. The makespan of a schedule is the time from the start to the finish of all jobs. Finally, the parallel scheduling problem asks us to compute the schedule with the smallest possible makespan.

(a) Prove that the parallel scheduling problem is NP-hard. (b) Give an algorithm that computes a 3-approximation of the minimum makespan of a set of jobs in O ( m log m ) time. That is, if the minimum makespan is M , your algorithm should compute a schedule with make-span at most 3 M. You can assume that n is a power of 2.

  1. Consider the greedy algorithm for metric TSP: start at an arbitrary vertex u , and at each step, travel to the closest unvisited vertex.

(a) Show that the greedy algorithm for metric TSP is an O (log n )-approximation, where n is the number of vertices. [Hint: Argue that the k th least expensive edge in the tour output by the greedy algorithm has weight at most OPT / ( n − k + 1 ); try k = 1 and k = 2 first.] ? (b) Show that the greedy algorithm for metric TSP is no better than an O (log n )-approximation. That is, describe an infinite family of weighted graphs such that the greedy algorithm returns a cycle whose weight is Ω(log n ) times the optimal TSP tour.

© c Copyright 2008 Jeff Erickson. Released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License (http://creativecommons.org/licenses/by-nc-sa/3.0/). Free distribution is strongly encouraged; commercial distribution is expressly forbidden. See http://www.cs.uiuc.edu/~jeffe/teaching/algorithms/ for the most recent revision.