Cap.8 EvaTardos

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 102

Chapter 8

NP and Computational Intractability


We now arrive at a major transition point in the book. Up until now, weve developed efcient algorithms for a wide range of problems and have even made some progress on informally categori ing the problems that admit efcient solutions!for e"ample, problems e"pressible as minimum cuts in a graph, or problems that allow a dynamic programming formulation. #ut although weve often paused to take note of other problems that we dont see how to solve, we havent yet made any attempt to actually $uantify or characteri e the range of problems that cant be solved efciently. #ack when we were rst laying out the fundamental denitions, we settled on polynomial time as our working notion of efciency. %ne advantage of using a concrete denition like this, as we noted earlier, is that it gives us the opportunity to prove mathematically that certain problems cannot be solved by polynomial-time!and hence &efcient'!algorithms. When people began investigating computational comple"ity in earnest, there was some initial progress in proving that certain extremely hard problems cannot be solved by efcient algorithms. #ut for many of the most fundamental discrete computational problems!arising in optimi ation, articial intelligence, combinatorics, logic, and elsewhere!the $uestion was too difcult to resolve, and it has remained open since then( We do not know of polynomial-time algorithms for these problems, and we cannot prove that no polynomial-time algorithm e"ists. )n the face of this formal ambiguity, which becomes increasingly hardened as years pass, people working in the study of comple"ity have made signicant progress. * large class of problems in this &gray area' has been characteri ed, and it has been proved that they are e$uivalent in the following sense( a polynomial-time algorithm for any one of them would imply the e"istence of a

196

+hapter ,

-. and +omputational )ntractability

polynomial-time algorithm for all of them. /hese are the NP-complete problems, a name that will make more sense as we proceed a little further. /here are literally thousands of -.-complete problems, arising in numerous areas, and the class seems to contain a large fraction of the fundamental problems whose comple"ity we cant resolve. 0o the formulation of -.-completeness, and the proof that all these problems are e$uivalent, is a powerful thing( it says that all these open $uestions are really a single open $uestion, a single type of comple"ity that we dont yet fully understand. 1rom a pragmatic point of view, -.-completeness essentially means &com- putationally hard for all practical purposes, though we cant prove it.' 2iscov- ering that a problem is -.-complete provides a compelling reason to stop searching for an efcient algorithm!you might as well search for an efcient algorithm for any of the famous computational problems already known to be -.-complete, for which many people have tried and failed to nd efcient algorithms.

,.3 .olynomial-/ime 4eductions


%ur plan is to e"plore the space of computationally hard problems, eventually arriving at a mathematical characteri ation of a large class of them. %ur basic techni$ue in this e"ploration is to compare the relative difculty of different problems5 wed like to formally e"press statements like, &.roblem X is at least as hard as problem Y .' We will formali e this through the notion of reduction( we will show that a particular problem X is at least as hard as some other problem Y by arguing that, if we had a &black bo"' capable of solving X , then we could also solve Y . 6)n other words, X is powerful enough to let us solve Y .7 /o make this precise, we add the assumption that X can be solved in polynomial time directly to our model of computation. 0uppose we had a black box that could solve instances of a problem X 5 if we write down the input for an instance of X , then in a single step, the black bo" will return the correct answer. We can now ask the following $uestion( ! "an arbitrary instances of problem Y be solved using a polynomial number of standard computational steps# plus a polynomial number of calls to a black box that solves problem X $ )f the answer to this $uestion is yes, then we write Y P X 5 we read this as &Y is polynomial-time reducible to X ,' or &X is at least as hard as Y 6with respect to polynomial time7.' -ote that in this denition, we still pay for the time it takes to write down the input to the black bo" solving X , and to read the answer that the black bo" provides.

,.3 .olynomial-/ime 4eductions

197

/his formulation of reducibility is very natural. When we ask about reductions to a problem X , it is as though weve supplemented our computational model with a piece of speciali ed hardware that solves instances of X in a single step. We can now e"plore the $uestion( 8ow much e"tra power does this piece of hardware give us9 *n important conse$uence of our denition of :P is the following. 0uppose Y :P X and there actually exists a polynomial-time algorithm to solve X . /hen our speciali ed black bo" for X is actually not so valuable5 we can replace it with a polynomial-time algorithm for X . +onsider what happens to our algorithm for problem Y that involved a polynomial number of steps plus a polynomial number of calls to the black bo". )t now becomes an algorithm that involves a polynomial number of steps, plus a polynomial number of calls to a subroutine that runs in polynomial time5 in other words, it has become a polynomial-time algorithm. We have therefore proved the following fact. 6,.37 %uppose Y :P X . &f X can be solved in polynomial time# then Y can be solved in polynomial time. Weve made use of precisely this fact, implicitly, at a number of earlier points in the book. 4ecall that we solved the #ipartite ;atching .roblem using a polynomial amount of preprocessing plus the solution of a single instance of the ;a"imum-1low .roblem. 0ince the ;a"imum-1low .roblem can be solved in polynomial time, we concluded that #ipartite ;atching could as well. 0imilarly, we solved the foreground<background )mage 0egmentation .roblem using a polynomial amount of preprocessing plus the solution of a single instance of the ;inimum-+ut .roblem, with the same conse$uences. #oth of these can be viewed as direct applications of 6,.37. )ndeed, 6,.37 summari es a great way to design polynomial-time algorithms for new problems( by reduction to a problem we already know how to solve in polynomial time. )n this chapter, however, we will be using 6,.37 to establish the computational intractability of various problems. We will be engaged in the somewhat subtle activity of relating the tractability of problems even when we dont know how to solve either of them in polynomial time. 1or this purpose, we will really be using the contrapositive of 6,.37, which is sufciently valuable that well state it as a separate fact. 6,.=7 %uppose Y :P X . &f Y cannot be solved in polynomial time# then X cannot be solved in polynomial time. 0tatement 6,.=7 is transparently e$uivalent to 6,.37, but it emphasi es our overall plan( )f we have a problem Y that is known to be hard, and we show

198

+hapter ,

-. and +omputational )ntractability

that Y P X , then the hardness has &spread' to X 5 X must be hard or else it could be used to solve Y . )n reality, given that we dont actually know whether the problems were studying can be solved in polynomial time or not, well be using P to establish relative levels of difculty among problems. With this in mind, we now establish some reducibilities among an initial collection of fundamental hard problems.

A First Reduction: Independent Set and Vertex Cover


/he )ndependent 0et .roblem, which we introduced as one of our ve representative problems in +hapter 3, will serve as our rst prototypical e"ample of a hard problem. We dont know a polynomial-time algorithm for it, but we also dont know how to prove that none e"ists. Cets review the formulation of )ndependent 0et, because were going to add one wrinkle to it. 4ecall that in a graph ' ( , )!, we say a set of nodes % ! ( is independent if no two nodes in % are joined by an edge. )t is easy to nd small independent sets in a graph 6for e"ample, a single node forms an independent set75 the hard part is to nd a large independent set, since you need to build up a large collection of nodes without ever including two neighbors. 1or e"ample, the set of nodes ">, ?, @# is an independent set of si e > in the graph in 1igure ,.3, while the set of nodes "3, ?, @, A# is a larger independent set. )n +hapter 3, we posed the problem of nding the largest independent set in a graph ' . 1or purposes of our current e"ploration in terms of reducibility, it will be much more convenient to work with problems that have yes<no answers only, and so we phrase )ndependent 0et as follows. 'iven a graph ' and a number k# does ' contain an independent set of si*e at least k$ )n fact, from the point of view of polynomial-time solvability, there is not a signicant difference between the optimi*ation version of the problem 6nd the ma"imum si e of an independent set7 and the decision version 6decide, yes or no, whether ' has an independent set of si e at least a given k7. Diven a method to solve the optimi ation version, we automatically solve the decision version 6for any k7 as well. #ut there is also a slightly less obvious converse to this( )f we can solve the decision version of )ndependent 0et for every k, then we can also nd a ma"imum independent set. 1or given a graph ' on n nodes, we simply solve the decision version of )ndependent 0et for each k5 the largest k for which the answer is &yes' is the si e of the largest independent set in '. 6*nd using binary search, we need only solve the decision version

>

Figure 8.1 A graph whose largest independent set has size 4, and whose smallest vertex cover has size 3.

for + log n! different values of k.7 /his simple e$uivalence between decision and optimi ation will also hold in the problems we discuss below. -ow, to illustrate our basic strategy for relating hard problems to one another, we consider another fundamental graph problem for which no efcient algorithm is known( (ertex "over . Diven a graph ' ( , )!, we say that a set of nodes % ! ( is a vertex cover if every edge e $ ) has at least one end in %. -ote the following fact about this use of terminology( )n a verte" cover, the vertices do the &covering,' and the edges are the objects being &covered.' -ow, it is easy to nd large verte" covers in a graph 6for e"ample, the full verte" set is one75 the hard part is to nd small ones. We formulate the Eerte" +over .roblem as follows. 'iven a graph ' and a number k# does ' contain a vertex cover of si*e at most k$ 1or e"ample, in the graph in 1igure ,.3, the set of nodes "3, =, A, B# is a verte" cover of si e ?, while the set "=, >, B# is a verte" cover of si e >. We dont know how to solve either )ndependent 0et or Eerte" +over in polynomial time5 but what can we say about their relative difculty9 We now show that they are e$uivalently hard, by establishing that )ndependent 0et P Eerte" +over and also that Eerte" +over P )ndependent 0et. /his will be a direct conse$uence of the following fact. 6,.>7 ,et ' ( , )! be a graph. -hen % is an independent set if and only if its complement ( % % is a vertex cover. .roof. 1irst, suppose that % is an independent set. +onsider an arbitrary edge e u , v!. 0ince % is independent, it cannot be the case that both u and v are in %5 so one of them must be in ( % %. )t follows that every edge has at least one end in ( % %, and so ( % % is a verte" cover. +onversely, suppose that ( % % is a verte" cover. +onsider any two nodes u and v in %. )f they were joined by edge e , then neither end of e would lie in ( % %, contradicting our assumption that ( % % is a verte" cover. )t follows that no two nodes in % are joined by an edge, and so % is an independent set.

4eductions in each direction between the two problems follow immediately from 6,.>7. 6,.?7 )ndependent 0et P Eerte" +over.

.roof. )f we have a black bo" to solve Eerte" +over, then we can decide whether ' has an independent set of si e at least k by asking the black bo" whether ' has a verte" cover of si e at most n % k. 6,.@7 0et. .roof. )f we have a black bo" to solve )ndependent 0et, then we can decide whether has a verte" set cover ofesiate least at most by an ' independent of si n kk . asking the black bo" whether ' has % /o sum up, this type of analysis illustrates our plan in general( although we dont know how to solve either )ndependent 0et or Eerte" +over efciently, 6,.?7 and 6,.@7 tell us how we could solve either given an efcient solution to the other, and hence these two facts establish the relative levels of difculty of these problems. We now pursue this strategy for a number of other problems. Eerte" +over P )ndependent

Reducing to a More Genera Case: Vertex Cover to Set Cover


)ndependent 0et and Eerte" +over represent two different genres of problems. )ndependent 0et can be viewed as a packing problem( /he goal is to &pack in' as many vertices as possible, subject to conFicts 6the edges7 that try to prevent one from doing this. Eerte" +over, on the other hand, can be viewed as a covering problem( /he goal is to parsimoniously &cover' all the edges in the graph using as few vertices as possible. Eerte" +over is a covering problem phrased specically in the language of graphs5 there is a more general covering problem, %et "over , in which you seek to cover an arbitrary set of objects using a collection of smaller sets. We can phrase 0et +over as follows. 'iven a set . of n elements# a collection %3, . . . , %m of subsets of . # and a number k# does there exist a collection of at most k of these sets /hose union is e0ual to all of . $ )magine, for e"ample, that we have m available pieces of software, and a set . of n capabilities that we would like our system to have. /he ith piece of software includes the set %i ! . of capabilities. )n the 0et +over .roblem, we seek to include a small number of these pieces of software on our system, with the property that our system will then have all n capabilities. 1igure ,.= shows a sample instance of the 0et +over .roblem( /he ten circles represent the elements of the underlying set . , and the seven ovals and polygons represent the sets %3, %= , . . . , %B. )n this instance, there is a collection

Figure 8.& An instance o' the (et )over *ro+lem.

of three of the sets whose union is e$ual to all of . ( We can choose the tall thin oval on the left, together with the two polygons. )ntuitively, it feels like Eerte" +over is a special case of 0et +over( in the latter case, we are trying to cover an arbitrary set using arbitrary subsets, while in the former case, we are specically trying to cover edges of a graph using sets of edges incident to vertices. )n fact, we can show the following reduction. 6,.A7 Eerte" +over :P 0et +over.

.roof. 0uppose we have access to a black bo" that can solve 0et +over, and consider an arbitrary instance of Eerte" +over, specied by a graph ' G ( , )! and a number k. 8ow can we use the black bo" to help us9

%ur goal is to cover the edges in ) , so we formulate an instance of 0et +over in which the ground set . is e$ual to ) . Hach time we pick a verte" in the Eerte" +over .roblem, we cover all the edges incident to it5 thus, for each verte" i $ ( , we add a set %i ! . to our 0et +over instance, consisting of all the edges in ' incident to i. We now claim that . can be covered with at most k of the sets %3, . . . , %n if and only if ' has a verte" cover of si e at most k. /his can be proved very easily. 1or if %i3 , . . . , %i are k sets that cover . , then every edge in ' is incident to one of the vertices i3, . . . , i , and so the set "i3, . . . , i # is a verte" cover in ' of si e k. +onversely, if "i3, . . . , i # is a verte" cover in ' of si e k, then the sets %i3 , . . . , %i cover . . /hus, given our instance of Eerte" +over, we formulate the instance of 0et +over described above, and pass it to our black bo". We answer yes if and only if the black bo" answers yes. 6Iou can check that the instance of 0et +over pictured in 1igure ,.= is actually the one youd get by following the reduction in this proof, starting from the graph in 1igure ,.3.7 8ere is something worth noticing, both about this proof and about the previous reductions in 6,.?7 and 6,.@7. *lthough the denition of P allows us to issue many calls to our black bo" for 0et +over, we issued only one. )ndeed, our algorithm for Eerte" +over consisted simply of encoding the problem as a single instance of 0et +over and then using the answer to this instance as our overall answer. /his will be true of essentially all the reductions that we consider5 they will consist of establishing Y P X by transforming our instance of Y to a single instance of X , invoking our black bo" for X on this instance, and reporting the bo"s answer as our answer for the instance of Y . Just as 0et +over is a natural generali ation of Eerte" +over, there is a natural generali ation of )ndependent 0et as a packing problem for arbitrary sets. 0pecically, we dene the %et Packing Problem as follows. 'iven a set . of n elements# a collection %3, . . . , %m of subsets of . # and a number k# does there exist a collection of at least k of these sets /ith the property that no t/o of them intersect$ )n other words, we wish to &pack' a large number of sets together, with the constraint that no two of them are overlapping. *s an e"ample of where this type of issue might arise, imagine that we have a set . of n non-sharable resources, and a set of m software processes. /he ith process re$uires the set %i ! . of resources in order to run. /hen the 0et .acking .roblem seeks a large collection of these processes that can be

run

,.= 4eductions via &Dadgets'( /he 0atisability .roblem

!"#

simultaneously, with the property that none of their resource re$uirements overlap 6i.e., represent a conFict7. /here is a natural analogue to 6,.A7, and its proof is almost the same as well5 we will leave the details as an e"ercise. 6,.B7 )ndependent 0et P 0et .acking.

,.= 4eductions via &Dadgets'( /he 0atisability .roblem


We now introduce a somewhat more abstract set of problems, which are formulated in #oolean notation. *s such, they model a wide range of problems in which we need to set decision variables so as to satisfy a given set of constraints5 such formalisms are common, for e"ample, in articial intelligence. *fter introducing these problems, we will relate them via reduction to the graph- and set-based problems that we have been considering thus far.

$%e SA$ 'ro( e)s

and

#&SA$

0uppose we are given a set X of n 1oolean variables x3, . . . , xn 5 each can take the value K or 3 6e$uivalently, &false' or &true'7. #y a term over X , we mean one of the variables xi or its negation xi . 1inally, a clause is simply a disjunction of distinct terms t3 , t= , . . . , t . 6*gain, each ti $ "x3, x= , . . . , xn , x3, . . . , xn #.7 We say the clause has length if it contains terms. We now formali e what it means for an assignment of values to satisfy a collection of clauses. * truth assignment for X is an assignment of the value K or 3 to each xi 5 in other words, it is a function 2 ( X . "K, 3#. /he assignment 2 implicitly gives xi the opposite truth value from xi . *n assignment satises a clause " if it causes " to evaluate to 3 under the rules of #oolean logic5 this is e$uivalent to re$uiring that at least one of the terms in " should receive the value 3. *n assignment satises a collection of clauses "3, . . . , "k if it causes all of the "i to evaluate to 35 in other words, if it causes the conjunction "3 - "= - . . . - "k to evaluate to 3. )n this case, we will say that 2 is a satisfying assignment with respect to "3, . . . , "k 5 and that the set of clauses "3, . . . , "k is satisable . 8ere is a simple e"ample. 0uppose we have the three clauses x3 , x=! , x3 , x>! , x= , x>!.

/hen the truth assignment 2 that sets all variables to 3 is not a satisfying assignment, because it does not satisfy the second of these clauses5 but the truth assignment 2 that sets all variables to K is a satisfying assignment. We can now state the %atisability Problem# also referred to as %3- ( 'iven a set of clauses "3, . . . , "k over a set of variables X G Lx3, . . . , xn M# does there exist a satisfying truth assignment$ /here is a special case of 0*/ that will turn out to be e$uivalently difcult and is somewhat easier to think about5 this is the case in which all clauses contain e"actly three terms 6corresponding to distinct variables7. We call this problem 4-%atisability, or 4-%3( 'iven a set of clauses "3, . . . , "k # each of length 4# over a set of variables X G Lx3, . . . , xn M# does there exist a satisfying truth assignment$ 0atisability and >-0atisability are really fundamental combinatorial search problems5 they contain the basic ingredients of a hard computational problem in very &bare-bones' fashion. We have to make n independent decisions 6the assignments for each xi 7 so as to satisfy a set of constraints. /here are several ways to satisfy each constraint in isolation, but we have to arrange our decisions so that all constraints are satised simultaneously.

Reducing #&SA$ to Independent Set


We now relate the type of computational hardness embodied in 0*/ and >- 0*/ to the supercially different sort of hardness represented by the search for independent sets and verte" covers in graphs. 0pecically, we will show that >-0*/ :P )ndependent 0et. /he difculty in proving a thing like this is clear5 >-0*/ is about setting #oolean variables in the presence of constraints, while )ndependent 0et is about selecting vertices in a graph. /o solve an instance of >-0*/ using a black bo" for )ndependent 0et, we need a way to encode all these #oolean constraints in the nodes and edges of a graph, so that satisability corresponds to the e"istence of a large independent set. 2oing this illustrates a general principle for designing comple" reductions Y :P X ( building &gadgets' out of components in problem X to represent what is going on in problem Y . 6,.,7 >-0*/ :P )ndependent 0et.

.roof. We have a black bo" for )ndependent 0et and want to solve an instance of >-0*/ consisting of variables X G Lx3, . . . , xn M and clauses "3, . . . , "k . /he key to thinking about the reduction is to reali e that there are two

conceptually distinct ways of thinking about an instance of >-0*/.

,.= 4eductions via &Dadgets'( /he 0atisability .roblem

!"* !"*

+onflict v33

*ny independent set contains at most one node from each triangle. +onflict v=3 ......... vk3

v3=

v3>

v==

v=>

v k=

vk>

+onflict
Figure 8.3 /he reduction 'rom 30(A/ to 1ndependent (et.

%ne way to picture the >-0*/ instance was suggested earlier( Iou have to make an independent K<3 decision for each of the n variables, and you succeed if you manage to achieve one of three ways of satisfying each clause. * different way to picture the same >-0*/ instance is as follows( Iou have to choose one term from each clause, and then nd a truth assignment that causes all these terms to evaluate to 3, thereby satisfying all clauses. 0o you succeed if you can select a term from each clause in such a way that no two selected terms &conFict'5 we say that two terms con5ict if one is e$ual to a variable xi and the other is e$ual to its negation xi . )f we avoid conFicting terms, we can nd a truth assignment that makes the selected terms from each clause evaluate to 3.

%ur reduction will be based on this second view of the >-0*/ instance5 here is how we encode it using independent sets in a graph. 1irst, construct a graph ' G ( , )! consisting of >k nodes grouped into k triangles as shown in 1igure ,.>. /hat is, for i G 3, =, . . . , k, we construct three vertices vi3, vi= , vi> joined to one another by edges. We give each of these vertices a label 5 vi6 is labeled with the 6 th term from the clause "i of the >-0*/ instance. #efore proceeding, consider what the independent sets of si e k look like in this graph( 0ince two vertices cannot be selected from the same triangle, they consist of all ways of choosing one verte" from each of the triangles. /his is implementing our goal of choosing a term in each clause that will evaluate to 35 but we have so far not prevented ourselves from choosing two terms that conFict.

We encode conFicts by adding some more edges to the graph( 1or each pair of vertices whose labels correspond to terms that conFict, we add an edge between them. 8ave we now destroyed all the independent sets of si e k, or does one still e"ist9 )ts not clear5 it depends on whether we can still select one node from each triangle so that no conFicting pairs of vertices are chosen. #ut this is precisely what the >-0*/ instance re$uired. Cets claim, precisely, that the original >-0*/ instance is satisable if and only if the graph ' we have constructed has an independent set of si e at least k. 1irst, if the >-0*/ instance is satisable, then each triangle in our graph contains at least one node whose label evaluates to 3. Cet % be a set consisting of one such node from each triangle. We claim % is independent5 for if there were an edge between two nodes u , v $ %, then the labels of u and v would have to conFict5 but this is not possible, since they both evaluate to 3. +onversely, suppose our graph ' has an independent set % of si e at least k. /hen, rst of all, the si e of % is e"actly k, and it must consist of one node from each triangle. -ow, we claim that there is a truth assignment 2 for the variables in the >-0*/ instance with the property that the labels of all nodes in % evaluate to 3. 8ere is how we could construct such an assignment 2 . 1or each variable xi , if neither xi nor xi appears as a label of a node in %, then we arbitrarily set 2 xi ! 3. %therwise, e"actly one of xi or xi appears as a label of a node in %5 for if one node in % were labeled xi and another were labeled xi , then there would be an edge between these two nodes, contradicting our assumption that % is an independent set. /hus, if xi appears as a label of a node in %, we set 2 xi ! 3, and otherwise we set 2 xi ! K. #y constructing 2 in this way, all labels of nodes in % will evaluate to 3. stance is satisable, the reduction is complete. 0ince ' has an independent set of si e at least k if and only if the original >-0*/ in

So)e Fina +(servations: $ransitivit, o- Reductions


Weve now seen a number of different hard problems, of various Favors, and weve discovered that they are closely related to one another. We can infer a number of additional relationships using the following fact( P is a transitive relation. 6,.N7 X. .roof. Diven a black bo" for X , we show how to solve an instance of hat solves Y two using a black bo" for X . 7 5 essentially, we justinstances compose of the algorithms implied by 7 P Y and Y P X . We run the algorithm for 7 using a black bo" for Y 5 but each time the black bo" for Y is called, we simulate it in a polynomial number of steps &f 7 P Y # and Y P X # then 7 P

using the algorithm t

,.> Hfcient +ertication and the 2enition of -.

!"7

/ransitivity can be $uite useful. 1or e"ample, since we have proved >-0*/ P )ndependent 0et P Eerte" +over P 0et +over, we can conclude that >-0*/ P 0et +over.

,.> Hfcient +ertication and the 2enition of -.


4educibility among problems was the rst main ingredient in our study of computational intractability. /he second ingredient is a characteri ation of the class of problems that we are dealing with. +ombining these two ingredients, together with a powerful theorem of +ook and Cevin, will yield some surprising conse$uences. 4ecall that in +hapter 3, when we rst encountered the )ndependent 0et .roblem, we asked( +an we say anything good about it, from a computational point of view9 *nd, indeed, there was something( )f a graph does contain an independent set of si e at least k, then we could give you an easy proof of this fact by e"hibiting such an independent set. 0imilarly, if a >-0*/ instance is satisable, we can prove this to you by revealing the satisfying assignment. )t may be an enormously difcult task to actually nd such an assignment5 but if weve done the hard work of nding one, its easy for you to plug it into the clauses and check that they are all satised. /he issue here is the contrast between nding a solution and checking a proposed solution. 1or )ndependent 0et or >-0*/, we do not know a polynomial-time algorithm to nd solutions5 but checking a proposed solution to these problems can be easily done in polynomial time. /o see that this is not an entirely trivial issue, consider the problem wed face if we had to prove that a >-0*/ instance was not satisable. What &evidence' could we show that would convince you, in polynomial time, that the instance was unsatisable9

'ro( e)s and A gorit%)s


/his will be the cru" of our characteri ation5 we now proceed to formali e it. /he input to a computational problem will be encoded as a nite binary string s. We denote the length of a string s by 2s2. We will identify a decision problem X with the set of strings on which the answer is &yes.' *n algorithm 3 for a decision problem receives an input string s and returns the value &yes' or &no'!we will denote this returned value by 3 s!. We say that 3 solves the problem X if for all strings s, we have 3 s! yes if and only if s $ X . *s always, we say that 3 has a polynomial running time if there is a polynomial function p 3! so that for every input string s, the algorithm 3 terminates on s in at most + p 2s2!! steps. /hus far in the book, we have been concerned with problems solvable in polynomial time. )n the notation

!"8

+hapter ,

-. and +omputational )ntractability

above, we can e"press this as the set . of all problems X for which there e"ists an algorithm 3 with a polynomial running time that solves X .

.-/cient Certi/cation
-ow, how should we formali e the idea that a solution to a problem can be checked efciently, independently of whether it can be solved efciently9 * &checking algorithm' for a problem X has a different structure from an algorithm that actually seeks to solve the problem5 in order to &check' a solution, we need the input string s, as well as a separate &certicate' string t that contains the evidence that s is a &yes' instance of X . /hus we say that 1 is an efcient certier for a problem X if the following properties hold.
. .

1 is a polynomial-time algorithm that takes two input arguments s and t . /here is a polynomial function p so that for every string s, we have s $ X if and only if there e"ists a string t such that 2t 2 p 2s2! and 1 s , t! yes.

)t takes some time to really think through what this denition is saying. %ne should view an efcient certier as approaching a problem X from a &managerial' point of view. )t will not actually try to decide whether an input s belongs to X on its own. 4ather, it is willing to efciently evaluate proposed &proofs' t that s belongs to X !provided they are not too long!and it is a correct algorithm in the weak sense that s belongs to X if and only if there e"ists a proof that will convince it. *n efcient certier 1 can be used as the core component of a &bruteforce' algorithm for a problem X ( %n an input s, try all strings t of length p 2s2!, and see if 1 s , t! yes for any of these strings. #ut the e"istence of 1 does not provide us with any clear way to design an efcient algorithm that actually solves X 5 after all, it is still up to us to nd a string t that will cause 1 s , t! to say &yes,' and there are e"ponentially many possibilities for t.

0': A C ass o- 'ro( e)s


We dene -. to be the set of all problems for which there e"ists an efcient certier.3 8ere is one thing we can observe immediately. 6,.3K7 -. . . !

/he act o' searching 'or a string t that will cause an e4cient certi5er to accept the input s is o'ten viewed as a nondeterministic search over the space o' possi+le proo's t 6

,.> Hfcient +ertication and the 2enition of -.

'or this reason, -. was named as an acron7m 'or 8nondeterministic pol7nomial time.9

!"9

!1"

+hapter ,

-. and +omputational )ntractability

.roof. +onsider a problem X $ .5 this means that there is a polynomial-time algorithm 3 that solves X . /o show that X $ -., we must show that there is an efcient certier 1 for X . /his is very easy5 we design 1 as follows. When presented with the input pair s , t!, the certier 1 simply returns the value 3 s!. 6/hink of 1 as a very &hands-on' manager that ignores the proposed proof t and simply solves the problem on its own.7 Why is 1 an efcient certier for X 9 +learly it has polynomial running time, since 3 does. )f a string s $ X , then for every t of length at most p 2s2!, we have 1 s , t! yes. %n the other hand, if s $ X , p s !, we2 have 1 s , t! no. then for every t of length ost at m 2 We can easily check that the problems introduced in the rst two sections belong to -.( it is a matter of determining how an efcient certier for each of them will make use of a &certicate' string t . 1or e"ample(
.

1or the >-0atisability .roblem, the certicate t is an assignment of truth values to the variables5 the certier 1 evaluates the given set of clauses with respect to this assignment. 1or the )ndependent 0et .roblem, the certicate t is the identity of a set of at least k vertices5 the certier 1 checks that, for these vertices, no edge joins any pair of them. 1or the 0et +over .roblem, the certicate t is a list of k sets from the given collection5 the certier checks that the union of these sets is e$ual to the underlying set . .

Iet we cannot prove that any of these problems re$uire more than polynomial time to solve. )ndeed, we cannot prove that there is any problem in -. that does not belong to .. 0o in place of a concrete theorem, we can only ask a $uestion( 6,.337 &s there a problem in -. that does not belong to .$ 8oes . -. $

/he $uestion of whether . -. is fundamental in the area of algorithms, and it is one of the most famous problems in computer science. /he general belief is that . -.!and this is taken as a working hypothesis throughout the eld!but there is not a lot of hard technical evidence for it. )t is more based on the sense that . -. would be too ama ing to be true. 8ow could there be a general transformation from the task of checking a solution to the much harder task of actually nding a solution9 8ow could there be a general means for designing efcient algorithms, powerful enough to handle all these hard problems, that we have somehow failed to discover9 ;ore generally, a huge amount of effort has gone into failed attempts at designing polynomial-time algorithms for hard problems in -.5 perhaps the most natural e"planation

,.> Hfcient +ertication and the 2enition of -.

!11

for this consistent failure is that these problems simply cannot be solved in polynomial time.

,.? -.-+omplete .roblems


)n the absence of progress on the . -. $uestion, people have turned to a related but more approachable $uestion( What are the hardest problems in -.9 .olynomial-time reducibility gives us a way of addressing this $uestion and gaining insight into the structure of -.. *rguably the most natural way to dene a &hardest' problem X is via the following two properties( 6i7 X $ -.5 and 6ii7 for all Y $ -., Y P X . )n other words, we re$uire that every problem in -. can be reduced to X . We will call such an X an NP-complete problem. /he following fact helps to further reinforce our use of the term hardest . 6,.3=7 %uppose X is an NP-complete problem. -hen X is solvable in polynomial time if and only if . -. . .roof. +learly, if . -., then X can be solved in polynomial time since it belongs to -.. +onversely, suppose that X can be solved in polynomial time. )f Y is any other problem in -., then Y P X , and so by 6,.37, it follows that Y can be solved in polynomial time. 8ence -. ! .5 combined with 6,.3K7, we have the desired conclusion.

* crucial conse$uence of 6,.3=7 is the following( )f there is any problem in -. that cannot be solved in polynomial time, then no -.-complete problem can be solved in polynomial time.

Circuit Satis/a(i it,: A First 0'&Co)p ete 'ro( e)


%ur denition of -.-completeness has some very nice properties. #ut before we get too carried away in thinking about this notion, we should stop to notice something( it is not at all obvious that -.-complete problems should even exist . Why couldnt there e"ist two incomparable problems X and X , so that there is no X $ -. with the property that X P X and X P X 9 Why couldnt there e"ist an innite se$uence of problems X3, X= , X>, . . . in -., each strictly harder than the previous one9 /o prove a problem is -.complete, one must show how it could encode any problem in -.. /his is a much trickier matter than what we encountered in 0ections ,.3 and ,.=, where we sought to encode specic, individual problems in terms of others.

,.? -.-+omplete .roblems

!11

)n 3NB3, +ook and Cevin independently showed how to do this for very natural problems in -.. ;aybe the most natural problem choice for a rst -.-complete problem is the following "ircuit %atisability Problem. /o specify this problem, we need to make precise what we mean by a circuit . +onsider the standard #oolean operators that we used to dene the 0atisability .roblem( - 6*-27, , 6%47, and : 6-%/7. %ur denition of a circuit is designed to represent a physical circuit built out of gates that implement these operators. /hus we dene a circuit 9 to be a labeled, directed acyclic graph such as the one shown in the e"ample of 1igure ,.?.
.

/he sources in 9 6the nodes with no incoming edges7 are labeled either with one of the constants K or 3, or with the name of a distinct variable. /he nodes of the latter type will be referred to as the inputs to the circuit. Hvery other node is labeled with one of the #oolean operators -, ,, or :5 nodes labeled with - or , will have two incoming edges, and nodes labeled with : will have one incoming edge. /here is a single node with no outgoing edges, and it will represent the output: the result that is computed by the circuit.

* circuit computes a function of its inputs in the following natural way. We imagine the edges as &wires' that carry the K<3 value at the node they emanate from. Hach node v other than the sources will take the values on its incoming edge6s7 and apply the #oolean operator that labels it. /he result of this -, ,, or : operation will be passed along the edge6s7 leaving v. /he overall value computed by the circuit will be the value computed at the output node. 1or e"ample, consider the circuit in 1igure ,.?. /he leftmost two sources are preassigned the values 3 and K, and the ne"t three sources constitute the

%utput(

)nputs( 3 K

Figure 8.4 A circuit with three inputs, two additional sources that have assigned truth values, and one output.

!1!

+hapter ,

-. and +omputational )ntractability

inputs. )f the inputs are assigned the values 3, K, 3 from left to right, then we get values K, 3, 3 for the gates in the second row, values 3, 3 for the gates in the third row, and the value 3 for the output. -ow, the +ircuit 0atisability .roblem is the following. We are given a circuit as input, and we need to decide whether there is an assignment of values to the inputs that causes the output to take the value 3. 6)f so, we will say that the given circuit is satisable , and a satisfying assignment is one that results in an output of 3.7 )n our e"ample, we have just seen!via the assignment 3, K, 3 to the inputs!that the circuit in 1igure ,.? is satisable. We can view the theorem of +ook and Cevin as saying the following. 6,.3>7 +ircuit 0atisability is NP-complete.

*s discussed above, the proof of 6,.3>7 re$uires that we consider an arbitrary problem X in -., and show that X P +ircuit 0atisability. We wont describe the proof of 6,.3>7 in full detail, but it is actually not so hard to follow the basic idea that underlies it. We use the fact that any algorithm that takes a "ed number n of bits as input and produces a yes<no answer can be represented by a circuit of the type we have just dened( /his circuit is e$uivalent to the algorithm in the sense that its output is 3 on precisely the inputs for which the algorithm outputs yes. ;oreover, if the algorithm takes a number of steps that is polynomial in n, then the circuit has polynomial si e. /his transformation from an algorithm to a circuit is the part of the proof of 6,.3>7 that we wont go into here, though it is $uite natural given the fact that algorithms implemented on physical computers can be reduced to their operations on an underlying set of -, ,, and : gates. 6-ote that "ing the number of input bits is important, since it reFects a basic distinction between algorithms and circuits( an algorithm typically has no trouble dealing with different inputs of varying lengths, but a circuit is structurally hard-coded with the si e of the input.7 8ow should we use this relationship between algorithms and circuits9 We are trying to show that X P +ircuit 0atisability!that is, given an input s, we want to decide whether s $ X using a black bo" that can solve instances of +ircuit 0atisability. -ow, all we know about X is that it has an efcient certier 1 3 , 3!. 0o to determine whether s $ X , for some specic input s of length n, we need to answer the following $uestion( )s there a t of length p n! so that 1 s , t! yes9 We will answer this $uestion by appealing to a black bo" for +ircuit 0atisability as follows. 0ince we only care about the answer for a specic input s, we view 1 3 , 3! as an algorithm on n ; p n! bits 6the input s and the

,.? -.-+omplete .roblems

!1#

certicate t 7, and we convert it to a polynomial-si e circuit 9 with n ; p n! sources. /he rst n sources will be hard-coded with the values of the bits in s, and the remaining p n! sources will be labeled with variables representing the bits of t 5 these latter sources will be the inputs to 9 . -ow we simply observe that s $ X if and only if there is a way to set the input bits to 9 so that the circuit produces an output of 3!in other words, if and only if 9 is satisable. /his establishes that X P "ircuit %atisability, and completes the proof of 6,.3>7. An Example /o get a better sense for whats going on in the proof of 6,.3>7, we consider a simple, concrete e"ample. 0uppose we have the following problem. 'iven a graph '# does it contain a t/o-node independent set$ -ote that this problem belongs to -.. Cets see how an instance of this problem can be solved by constructing an e$uivalent instance of +ircuit 0atisability. 1ollowing the proof outline above, we rst consider an efcient certier for this problem. /he input s is a graph on n nodes, which will be specied n by = bits( 1or each pair of nodes, there will be a bit saying whether there is an edge joining this pair. /he certicate t can be specied by n bits( 1or each node, there will be a bit saying whether this node belongs to the proposed independent set. /he efcient certier now needs to check two things( that at least two of the bits in t are set to 3, and that no two bits in t are both set to 3 if they form the two ends of an edge 6as determined by the corresponding bit in s7. -ow, for the specic input length n corresponding to the s that we are interested in, we construct an e$uivalent circuit 9 . 0uppose, for e"ample, that we are interested in deciding the answer to this problem for a graph ' on the three nodes u , v , /, in which v is joined to both u and /. /his means that we are concerned with an input of length n >. 1igure ,.@ shows a circuit that is e$uivalent to an efcient certier for our problem on arbitrary threenode graphs. 6Hssentially, the right-hand side of the circuit checks that at least two nodes have been selected, and the left-hand side checks that we havent selected both ends of any edge.7 We encode the edges of ' as constants in the rst three sources, and we leave the remaining three sources 6representing the choice of nodes to put in the independent set7 as variables. -ow observe that this instance of +ircuit 0atisability is satisable, by the assignment 3, K, 3 to the inputs. /his corresponds to choosing nodes u and /, which indeed form a two-node independent set in our three-node graph '.

!11

+hapter ,

-. and +omputational )ntractability

8ave both ends of some edge been chosen9

8ave at least two nodes been chosen9

u,v 3

u,/ K

v ,/ 3

Figure 8.< A circuit to veri'7 whether a >0node graph contains a =0node independent set.

'roving Furt%er 'ro( e)s 0'&Co)p ete


0tatement 6,.3>7 opens the door to a much fuller understanding of hard problems in -.( %nce we have our hands on a rst -.-complete problem, we can discover many more via the following simple observation. 6,.3?7 &f Y is an NP-complete problem# and X is a problem in -. /ith the property that Y P X # then X is NP-complete. .roof. 0ince X $ -., we need only verify property 6ii7 of the denition. 0o let 7 be any problem in -.. We have 7 P Y , by the -.-completeness of Y , and Y P X by assumption. #y 6,.N7, it follows that 7 X P . 0o while proving 6,.3>7 re$uired the hard work of considering any possible problem in -., proving further problems -.-complete only re$uires a reduction from a single problem already known to be -.-complete, thanks to 6,.3?7.

,.? -.-+omplete .roblems

!1* !1*

)n earlier sections, we have seen a number of reductions among some basic hard problems. /o establish their -.-completeness, we need to connect +ircuit 0atisability to this set of problems. /he easiest way to do this is by relating it to the problem it most closely resembles, >-0atisability. 6,.3@7 >-0atisability is NP-complete.

.roof. +learly >-0atisability is in -., since we can verify in polynomial time that a proposed truth assignment satises the given set of clauses. We will prove that it is -.-complete via the reduction +ircuit 0atisability P >-0*/. Diven an arbitrary instance of +ircuit 0atisability, we will rst construct an e$uivalent instance of 0*/ in which each clause contains at most three variables. /hen we will convert this 0*/ instance to an e$uivalent one in which each clause has exactly three variables. /his last collection of clauses will thus be an instance of >-0*/, and hence will complete the reduction. 0o consider an arbitrary circuit 9 . We associate a variable xv with each node v of the circuit, to encode the truth value that the circuit holds at that node. -ow we will dene the clauses of the 0*/ problem. 1irst we need to encode the re$uirement that the circuit computes values correctly at each gate from the input values. /here will be three cases depending on the three types of gates.
.

)f node v is labeled with :, and its only entering edge is from node u , then we need to have xv xu . We guarantee this by adding two clauses xv , xu !, and xv , xu !. )f node v is labeled with ,, and its two entering edges are from nodes u and /, we need to have xv xu , x/ . We guarantee this by adding the following clauses( xv , xu !, xv , x/ !, and xv , xu , x/ !. )f node v is labeled with -, and its two entering edges are from nodes u and /, we need to have xv xu - x/ . We guarantee this by adding the following clauses( xv , xu !, xv , x/ !, and xv , xu , x/ !.

1inally, we need to guarantee that the constants at the sources have their specied values, and that the output evaluates to 3. /hus, for a source v that has been labeled with a constant value, we add a clause with the single variable xv or xv , which forces xv to take the designated value. 1or the output node o, we add the single-variable clause xo , which re$uires that o take the value 3. /his concludes the construction. )t is not hard to show that the 0*/ instance we just constructed is e$uivalent to the given instance of +ircuit 0atisability. /o show the e$uivalence, we need to argue two things. 1irst suppose that the given circuit 9 is satisable. /he satisfying assignment to the circuit inputs can be propagated to create

!16

+hapter ,

-. and +omputational )ntractability

values at all nodes in 9 6as we did in the e"ample of 1igure ,.?7. /his set of values clearly satises the 0*/ instance we constructed. /o argue the other direction, we suppose that the 0*/ instance we constructed is satisable. +onsider a satisfying assignment for this instance, and look at the values of the variables corresponding to the circuit 9 s inputs. We claim that these values constitute a satisfying assignment for the circuit 9 . /o see this, simply note that the 0*/ clauses ensure that the values assigned to all nodes of 9 are the same as what the circuit computes for these nodes. )n particular, a value of 3 will be assigned to the output, and so the assignment to inputs satises 9 . /hus we have shown how to create a 0*/ instance that is e$uivalent to the +ircuit 0atisability .roblem. #ut we are not $uite done, since our goal was to create an instance of >-0*/, which re$uires that all clauses have length e"actly >!in the instance we constructed, some clauses have lengths of 3 or =. 0o to nish the proof, we need to convert this instance of 0*/ to an e$uivalent instance in which each clause has e"actly three variables. /o do this, we create four new variables( *3, *= , *>, *?. /he idea is to ensure that in any satisfying assignment, we have *3 *= K, and we do this by adding the clauses *i , *> , *?!, *i , *> , *?!, *i , *> , *?!, and *i , *> , *?! for each of i 3 and i =. -ote that there is no way to satisfy all these clauses unless we set *3 *= K. -ow consider a clause in the 0*/ instance we constructed that has a single term t 6where the term t can be either a variable or the negation of a variable7. We replace each such term by the clause t , *3 , *=!. 0imilarly, we replace each clause that has two terms, say, t , t !, with the clause t , t , *3!. /he resulting >-0*/ formula is clearly e$uivalent to the 0*/ formula with at most three bles varia in each clause, and this nishes the proof. Using this -.-completeness result, and the se$uence of reductions >-0*/ P )ndependent 0et P Eerte" +over P 0et +over, summari ed earlier, we can use 6,.3?7 to conclude the following. 6,.3A7 3ll of the follo/ing problems are NP-complete: )ndependent 0et# 0et .acking# Eerte" +over# and 0et +over. nce +ircuit 0atisability7 can be reduced to it. .roof. Hach of these problems has the property that it is in -. and that >0*/ 6and he

,.@ 0e$uencing .roblems

!17

Genera Strateg, -or 'roving 0e2 'ro( e)s 0'&Co)p ete


1or most of the remainder of this chapter, we will take off in search of further -.-complete problems. )n particular, we will discuss further genres of hard computational problems and prove that certain e"amples of these genres are -.-complete. *s we suggested initially, there is a very practical motivation in doing this( since it is widely believed that . -., the discovery that a problem is -.-complete can be taken as a strong indication that it cannot be solved in polynomial time. Diven a new problem X , here is the basic strategy for proving it is -.complete. 3. .rove that X $ -.. =. +hoose a problem Y that is known to be -.-complete. >. .rove that Y P X . We noticed earlier that most of our reductions Y P X consist of transforming a given instance of Y into a single instance of X with the same answer. /his is a particular way of using a black bo" to solve X 5 in particular, it re$uires only a single invocation of the black bo". When we use this style of reduction, we can rene the strategy above to the following outline of an -.-completeness proof. 3. .rove that X $ -.. =. +hoose a problem Y that is known to be -.-complete. >. +onsider an arbitrary instance sY of problem Y , and show how to construct, in polynomial time, an instance sX of problem X that satises the following properties( 6a7 )f sY is a &yes' instance of Y , then sX is a &yes' instance of X . 6b7 )f sX is a &yes' instance of X , then sY is a &yes' instance of Y. )n other words, this establishes that sY and sX have the same answer. /here has been research aimed at understanding the distinction between polynomial-time reductions with this special structure!asking the black bo" a single $uestion and using its answer verbatim!and the more general notion of polynomial-time reduction that can $uery the black bo" multiple times. 6/he more restricted type of reduction is known as a 9arp reduction, while the more general type is known as a "ook reduction and also as a polynomial-time -uring reduction.7 We will not be pursuing this distinction further here.

,.@ 0e$uencing .roblems


/hus far we have seen problems that 6like )ndependent 0et and Eerte" +over7 have involved searching over subsets of a collection of objects5 we have also

!18

+hapter ,

-. and +omputational )ntractability

seen problems that 6like >-0*/7 have involved searching over K<3 settings to a collection of variables. *nother type of computationally hard problem involves searching over the set of all permutations of a collection of objects.

$%e $rave ing Sa es)an 'ro( e)


.robably the most famous such se$uencing problem is the -raveling %alesman Problem. +onsider a salesman who must visit n cities labeled v3, v= , . . . , vn . /he salesman starts in city v3, his home, and wants to nd a tour !an order in which to visit all the other cities and return home. 8is goal is to nd a tour that causes him to travel as little total distance as possible. /o formali e this, we will take a very general notion of distance( for each ordered pair of cities vi , v6 !, we will specify a nonnegative number d vi , v6 ! as the distance from vi to v6 . We will not re$uire the distance to be symmetric 6so it may happen that d vi , v6 ! G d v6 , vi !7, nor will we re$uire it to satisfy the triangle ine$uality 6so it may happen that d vi , v6 ! plus d v6 , vk ! is actually less than the &direct' distance d vi , vk !7. /he reason for this is to make our formulation as general as possible. )ndeed, /raveling 0alesman arises naturally in many applications where the points are not cities and the traveler is not a salesman. 1or e"ample, people have used /raveling 0alesman formulations for problems such as planning the most efcient motion of a robotic arm that drills holes in n points on the surface of a EC0) chip5 or for serving )<% re$uests on a disk5 or for se$uencing the e"ecution of n software modules to minimi e the conte"t-switching time. /hus, given the set of distances, we ask( %rder the cities into a tour vi3 , vi= , . . . , vin , with i3 G 3, so as to minimi e the total distance 6 d vi6 , v i6O3 ! O d vin , vi3!. /he re$uirement i3 G 3 simply &orients' the tour so that it starts at the home city, and the terms in the sum simply give the distance from each city on the tour to the ne"t one. 6/he last term in the sum is the distance re$uired for the salesman to return home at the end.7 8ere is a decision version of the /raveling 0alesman .roblem.
3 =

'iven a set of distances on n cities# and a bound 8# is there a tour of length at most 8$
>

$%e 3a)i tonian C,c e 'ro( e)


@ ?

Figure 8.= A directed graph containing a >amiltonian c7cle.

/he /raveling 0alesman .roblem has a natural graph-based analogue, which forms one of the fundamental problems in graph theory. Diven a directed graph ' G ( , )!, we say that a cycle " in ' is a ;amiltonian cycle if it visits each verte" e"actly once. )n other words, it constitutes a &tour' of all the vertices, with no repetitions. 1or e"ample, the directed graph pictured in 1igure ,.A has

several 8amiltonian cycles5 one visits the nodes in the order 3, A, ?, >, =, @, 3, while another visits the nodes in the order 3, =, ?, @, A, >, 3. /he 8amiltonian +ycle .roblem is then simply the following( 'iven a directed graph '# does it contain a ;amiltonian cycle$

'roving Hamiltonian Cycle is 0'&Co)p ete


We now show that both these problems are -.-complete. We do this by rst establishing the -.-completeness of 8amiltonian +ycle, and then proceeding to reduce from 8amiltonian +ycle to /raveling 0alesman. 6,.3B7 8amiltonian +ycle is NP-complete.

.roof. We rst show that 8amiltonian +ycle is in -.. Diven a directed graph ' G ( , )!, a certicate that there is a solution would be the ordered list of the vertices on a 8amiltonian cycle. We could then check, in polynomial time, that this list of vertices does contain each verte" e"actly once, and that each consecutive pair in the ordering is joined by an edge5 this would establish that the ordering denes a 8amiltonian cycle. We now show that >-0*/ :P 8amiltonian +ycle. Why are we reducing from >-0*/9 Hssentially, faced with 8amiltonian +ycle, we really have no idea /hat to reduce from5 its sufciently different from all the problems weve seen so far that theres no real basis for choosing. )n such a situation, one strategy is to go back to >-0*/, since its combinatorial structure is very basic. %f course, this strategy guarantees at least a certain level of comple"ity in the reduction, since we need to encode variables and clauses in the language of graphs. 0o consider an arbitrary instance of >-0*/, with variables x3, . . . , xn and clauses "3, . . . , "k . We must show how to solve it, given the ability to detect 8amiltonian cycles in directed graphs. *s always, it helps to focus on the essential ingredients of >-0*/( We can set the values of the variables however we want, and we are given three chances to satisfy each clause. We begin by describing a graph that contains =n different 8amiltonian cycles that correspond very naturally to the =n possible truth assignments to the variables. *fter this, we will add nodes to model the constraints imposed by the clauses. We construct n paths P3, . . . , Pn , where Pi consists of nodes vi3, vi= , . . . , vib for a $uantity b that we take to be somewhat larger than the number of clauses k5 say, b G >k O >. /here are edges from vi6 to vi , 6O3 and in the other direction from vi , 6O3 to vi6 . /hus Pi can be traversed &left to right,' from vi3 to vib, or &right to left,' from vib to vi3.

8amiltonian cycles correspond to the =n possible truth assignments.

P3

P=

P>

t
Figure 8.? /he reduction 'rom 30(A/ to >amiltonian )7cle@ part 1.

We hook these paths together as follows. 1or each i G 3, =, . . . , n P 3, we dene edges from vi3 to viO3, 3 and to viO3, b. We also dene edges from vib to viO3, 3 and to viO3, b. We add two e"tra nodes s and t 5 we dene edges from s to v33 and v3b5 from vn3 and vnb to t 5 and from t to s. /he construction up to this point is pictured in 1igure ,.B. )ts important to pause here and consider what the 8amiltonian cycles in our graph look like. 0ince only one edge leaves t , we know that any 8amiltonian cycle + must use the edge t , s!. *fter entering s, the cycle + can then traverse P3 either left to right or right to left5 regardless of what it does here, it can then traverse P= either left to right or right to left5 and so forth, until it nishes traversing Pn and enters t . )n other words, there are e"actly =n different 8amiltonian cycles, and they correspond to the n independent choices of how to traverse each Pi .

/his naturally models the n independent choices of how to set each variables x3, . . . , xn in the >-0*/ instance. /hus we will identify each 8amiltonian cycle uni$uely with a truth assignment as follows( )f + traverses Pi left to right, then xi is set to 35 otherwise, xi is set to K. -ow we add nodes to model the clauses5 the >-0*/ instance will turn out to be satisable if and only if any 8amiltonian cycle survives. Cets consider, as a concrete e"ample, a clause "3 x3 , x= , x>.

)n the language of 8amiltonian cycles, this clause says, &/he cycle should traverse P3 left to right5 or it should traverse P= right to left5 or it should traverse P> left to right.' 0o we add a node c3, as in 1igure ,.,, that does just this. 6-ote that certain edges have been eliminated from this drawing, for the sake of clarity.7 1or some value of , node c3 will have edges from v3 , v=, ;3, and v> 5 it will have edges to v3, ;3, v=, , and v>, ;3. /hus it can be easily spliced into any 8amiltonian cycle that traverses P3 left to right by visiting node c3 between v3 and v3, ;35 similarly, c3 can be spliced into any 8amiltonian cycle that traverses P= right to left, or P> left to right. )t cannot be spliced into a 8amiltonian cycle that does not do any of these things. ;ore generally, we will dene a node c6 for each clause "6 . We will reserve node positions >6 and >6 ; 3 in each path Pi for variables that participate in clause "6 . 0uppose clause "6 contains a term t . /hen if t xi , we will add edges vi , >6 , c6 ! and c6 , vi , >6;3!5 if t xi , we will add edges vi , >6 ;3, c6 ! and c6 , vi , >6 !. /his completes the construction of the graph ' . -ow, following our generic outline for -.-completeness proofs, we claim that the >-0*/ instance is satisable if and only if ' has a 8amiltonian cycle. 1irst suppose there is a satisfying assignment for the >-0*/ instance. /hen we dene a 8amiltonian cycle following our informal plan above. )f xi is assigned 3 in the satisfying assignment, then we traverse the path Pi left to right5 otherwise we traverse Pi right to left. 1or each clause "6 , since it is satised by the assignment, there will be at least one path Pi in which we will be going in the &correct' direction relative to the node c6 , and we can splice it into the tour there via edges incident on vi , >6 and vi ,>6;3. +onversely, suppose that there is a 8amiltonian cycle + in ' . /he crucial thing to observe is the following. )f + enters a node c6 on an edge from vi ,>6 , it must depart on an edge to vi , >6;3. 1or if not, then vi , >6;3 will have only one unvisited neighbor left, namely, vi , >6;=, and so the tour will not be able to visit this node and still maintain the 8amiltonian property. 0ymmetrically, if it enters from vi , >6;3, it must depart immediately to vi , >6 . /hus, for each node c6 ,

c3 can only be visited if the cycle traverses some path in the correct direction. c3

P3

P=

P>

t
Figure 8.8 /he reduction 'rom 30(A/ to >amiltonian )7cle@ part &.

the nodes immediately before and after c6 in the cycle + are joined by an edge e in ' 5 thus, if we remove c6 from the cycle and insert this edge e for each 6 , then we obtain a 8amiltonian cycle + on the subgraph ' P Lc3, . . . , ck M. /his is our original subgraph, before we added the clause nodes5 as we noted above, any 8amiltonian cycle in this subgraph must traverse each Pi fully in one direction or the other. We thus use + to dene the following truth assignment for the >-0*/ instance. )f + traverses Pi left to right, then we set xi G 35 otherwise we set xi G K. 0ince the larger cycle + was able to visit each clause node c6 , at least one of the paths was traversed in the &correct' direction relative to the node c6 , and so the assignment we have dened satises all the clauses.

8aving established that the >-0*/ instance is satisable if and only if ' has a 8amiltonian cycle, our proof is complete.

'roving $rave ing Sa es)an is 0'&Co)p ete


*rmed with our basic hardness result for 8amiltonian +ycle, we can move on to show the hardness of /raveling 0alesman. 6,.3,7 /raveling 0alesman is NP-complete.

.roof. )t is easy to see that /raveling 0alesman is in -.( /he certicate is a permutation of the cities, and a certier checks that the length of the corresponding tour is at most the given bound. We now show a directed graph /raveling 0alesman. dene d v , v ! to be 3 if there is an that 8amiltonian +ycle :P /raveling 0alesman. Diven ' G ( , )!, we dene the following instance of We have a city v for each node vi of the graph '. We edge vi , v6 ! in ', and we dene it to be = otherwise.
i i 6

-ow we claim that ' has a 8amiltonian cycle if and only if there is tour of length at most n in our /raveling 0alesman instance. 1or if ' has a 8amiltonian cycle, then this ordering of the corresponding cities denes a tour of length n. +onversely, suppose there is a tour of length at most n. /he e"pression for the length of this tour is a sum of n terms, each of which is at least 35 thus it must be the case that all the terms are e$ual to 3. 8ence each pair of nodes in ' that correspond to consecutive cities on the tour must be connected by an edge5 it follows that the ordering of these corresponding nodes must form a 8am iltonian cycle. -ote that allowing asymmetric distances in the /raveling 0alesman .roblem 6d v i , v 6 ! G d v6 , vi !7 played a crucial role5 since the graph in the 8amiltonian +ycle instance is directed, our reduction yielded a /raveling 0alesman instance with asymmetric distances. )n fact, the analogue of the 8amiltonian +ycle .roblem for undirected graphs is also -.-complete5 although we will not prove this here, it follows via a not-too-difcult reduction from directed 8amiltonian +ycle. Using this undirected 8amiltonian +ycle .roblem, an e"act analogue of 6,.3,7 can be used to prove that the /raveling 0alesman .roblem with symmetric distances is also -.-complete. %f course, the most famous special case of the /raveling 0alesman .roblem is the one in which the distances are dened by a set of n points in the plane. )t is possible to reduce 8amiltonian +ycle to this special case as well, though this is much trickier.

.xtensions: $%e 3a)i tonian 'at% 'ro( e)


)t is also sometimes useful to think about a variant of 8amiltonian +ycle in which it is not necessary to return to ones starting point. /hus, given a directed graph ' G ( , )!, we say that a path P in ' is a ;amiltonian path if it contains each verte" e"actly once. 6/he path is allowed to start at any node and end at any node, provided it respects this constraint.7 /hus such a path consists of distinct nodes vi3 , vi= , . . . , vin in order, such that they collectively constitute the entire verte" set ( 5 by way of contrast with a 8amiltonian cycle, it is not necessary for there to be an edge from vin back to vi3. -ow, the ;amiltonian Path Problem asks( 'iven a directed graph '# does it contain a ;amiltonian path$ Using the hardness of 8amiltonian +ycle, we show the following. 6,.3N7 complete. 8amiltonian .ath is NP-

.roof. 1irst of all, 8amiltonian .ath is in -.( * certicate could be a path in ' , and a certier could then check that it is indeed a path and that it contains each node e"actly once. %ne way to show that 8amiltonian .ath is -.-complete is to use a reduction from >-0*/ that is almost identical to the one we used for 8amiltonian +ycle( We construct the same graph that appears in 1igure ,.B, except that we do not include an edge from t to s. )f there is any 8amiltonian path in this modied graph, it must begin at s 6since s has no incoming edges7 and end at t 6since t has no outgoing edges7. With this one change, we can adapt the argument used in the 8amiltonian +ycle reduction more or less word for word to argue that there is a satisfying assignment for the instance of >-0*/ if and only if there is a 8amiltonian path. *n alternate way to show that 8amiltonian .ath is -.-complete is to prove that 8amiltonian +ycle :P 8amiltonian .ath. Diven an instance of 8amiltonian +ycle, specied by a directed graph ', we construct a graph ' as follows. We choose an arbitrary node v in ' and replace it with two new nodes v and v . *ll edges out of v in ' are now out of v 5 and all edges into v in ' are now into v . ;ore precisely, each edge v , /! in ' is replaced by an edge v , /!5 and each edge u , v! in ' is replaced by an edge u , v !. /his completes the construction of ' . We claim that ' contains a 8amiltonian path if and only if ' contains a 8amiltonian cycle. )ndeed, suppose " is a 8amiltonian cycle in ' , and consider traversing it beginning and ending at node v. )t is easy to see that the same ordering of nodes forms a 8amiltonian path in ' that begins at v and ends at v . +onversely, suppose P is a 8amiltonian path in ' . +learly P must begin

,.A .artitioning .roblems

!!*

at v 6since v has no incoming edges7 and end at v 6since v has no outgoing edges7. )f we replace v and v with v, then this ordering of nodes forms a 8amiltonian cycle in '.

,.A .artitioning .roblems


)n the ne"t two sections, we consider two fundamental partitioning problems, in which we are searching over ways of dividing a collection of objects into subsets. 8ere we show the -.-completeness of a problem that we call 48imensional <atching . )n the ne"t section we consider 'raph "oloring , a problem that involves partitioning the nodes of a graph.

$%e #&4i)ensiona Matc%ing 'ro( e)


We begin by discussing the >-2imensional ;atching .roblem, which can be motivated as a harder version of the #ipartite ;atching .roblem that we considered earlier. We can view the #ipartite ;atching .roblem in the following way( We are given two sets X and Y , each of si e n, and a set P of pairs drawn from X A Y . /he $uestion is( 2oes there e"ist a set of n pairs in P so that each element in X B Y is contained in e"actly one of these pairs9 /he relation to #ipartite ;atching is clear( the set P of pairs is simply the edges of the bipartite graph. -ow #ipartite ;atching is a problem we know how to solve in polynomial time. #ut things get much more complicated when we move from ordered pairs to ordered triples. +onsider the following >-2imensional ;atching .roblem( 'iven dis6oint sets X # Y # and 7# each of si*e n# and given a set - ! X A Y A 7 of ordered triples# does there exist a set of n triples in so that each element of X B Y B 7 is contained in exactly one of these triples$ 0uch a set of triples is called a perfect three-dimensional matching. *n interesting thing about >-2imensional ;atching, beyond its relation to #ipartite ;atching, is that it simultaneously forms a special case of both 0et +over and 0et .acking( we are seeking to cover the ground set X B Y B 7 with a collection of dis6oint sets. ;ore concretely, 4-8imensional <atching is a special case of %et "over since we seek to cover the ground set . X B Y B 7 using at most n sets from a given collection 6the triples7. 0imilarly, >-2imensional ;atching is a special case of 0et .acking, since we are seeking n disjoint subsets of the ground set . X B Y B 7 .

'roving #&4i)ensiona Matc%ing Is 0'&Co)p ete


/he arguments above can be turned $uite easily into proofs that >-2imensional ;atching P 0et +over and that >-2imensional ;atching P 0et .acking.

!!6

+hapter ,

-. and +omputational )ntractability

#ut this doesnt help us establish the -.-completeness of >-2imensional ;atching, since these reductions simply show that >-2imensional ;atching can be reduced to some very hard problems. What we need to show is the other direction( that a known -.-complete problem can be reduced to >-2imensional ;atching.

6,.=K7

>-2imensional ;atching is NP-complete.

.roof. -ot surprisingly, it is easy to prove that >-2imensional ;atching is in -.. Diven a collection of triples - C X A Y A 7 , a certicate that there is a solution could be a collection of triples - ! - . )n polynomial time, one could verify that each element in X B Y B 7 belongs to e"actly one of the triples in - . 1or the reduction, we again return all the way to >-0*/. /his is perhaps a little more curious than in the case of 8amiltonian +ycle, since >2imensional ;atching is so closely related to both 0et .acking and 0et +over5 but in fact the partitioning re$uirement is very hard to encode using either of these problems. /hus, consider an arbitrary instance of >-0*/, with n variables x3, . . . , xn and k clauses "3, . . . , "k . We will show how to solve it, given the ability to detect perfect three-dimensional matchings. /he overall strategy in this reduction will be similar 6at a very high level7 to the approach we followed in the reduction from >-0*/ to 8amiltonian +ycle. We will rst design gadgets that encode the independent choices involved in the truth assignment to each variable5 we will then add gadgets that encode the constraints imposed by the clauses. )n performing this construction, we will initially describe all the elements in the >-2imensional ;atching instance simply as &elements,' without trying to specify for each one whether it comes from X , Y , or 7 . *t the end, we will observe that they naturally decompose into these three sets. 8ere is the basic gadget associated with variable xi . We dene elements 3i "ai3, ai= , . . . , ai ,=k # that constitute the core of the gadget5 we dene elements 1i "bi3, . . . , bi ,=k # at the tips of the gadget. 1or each 6 3, =, . . . , =k, we dene a triple ti6 ai6 , ai , 6 ;3, bi6 !, where we interpret addition modulo =k. /hree of these gadgets are pictured in 1igure ,.N. )n gadget i, we will call a triple ti6 even if 6 is even, and odd if 6 is odd. )n an analogous way, we will refer to a tip bi6 as being either even or odd. /hese will be the only triples that contain the elements in 3i , so we can already say something about how they must be covered in any perfect matching( we must either use all the even triples in gadget i, or all the odd triples in gadget i. /his will be our basic way of encoding the idea that xi can

,.A .artitioning .roblems

!!7

+lause 3

/he clause elements can only be matched if some variable gadget leaves the corresponding tip free.

+ore /ips Eariable 3 Eariable = Eariable >

Figure 8.D /he reduction 'rom 30(A/ to 30Eimensional Fatching.

be set to either K or 35 if we select all the even triples, this will represent setting xi K, and if we select all the odd triples, this will represent setting xi 3. 8ere is another way to view the odd<even decision, in terms of the tips of the gadget. )f we decide to use the even triples, we cover the even tips of the gadget and leave the odd tips free. )f we decide to use the odd triples, we cover the odd tips of the gadget and leave the even tips free. /hus our decision of how to set xi can be viewed as follows( Ceaving the odd tips free corresponds to K, while leaving the even tips free corresponds to 3. /his will actually be the more useful way to think about things in the remainder of the construction. 0o far we can make this even<odd choice independently for each of the n variable gadgets. We now add elements to model the clauses and to constrain the assignments we can choose. *s in the proof of 6,.3B7, lets consider the e"ample of a clause "3 x3 , x= , x>.

)n the language of three-dimensional matchings, it tells us, &/he matching on the cores of the gadgets should leave the even tips of the rst gadget free5 or it should leave the odd tips of the second gadget free5 or it should leave the even tips of the third gadget free.' 0o we add a clause gadget that does precisely

this. )t consists of a set of two core elements P3 G Lp3, p3 M, and three triples that contain them. %ne has the form3 p3, p , b36 ! for an even tip b36 5 another includes p3, p3, and an odd tip b=, 6 5 and a third includes p3, p3 , and an even tip b>, 6 . /hese are the only three triples that cover P3, so we know that one of them must be used5 this enforces the clause constraint e"actly. )n general, for clause "6 , we create a gadget with two core elements P6 G Lp6 ,6 p M, and we dene three triples containing P6 as follows. 0uppose
6 clause "6 contains a term t . )f t G xi , we dene a triple p6 , p , bi ,=6 !5 if t G xi , 6 we dene a triple p6 , p , bi ,=6P3!. -ote that only clause gadget 6 makes use of tips bim with m G =6 or m G =6 P 35 thus, the clause gadgets will never &compete' with each other for free tips.

We are almost done with the construction, but theres still one problem. 0uppose the set of clauses has a satisfying assignment. /hen we make the corresponding choices of odd<even for each variable gadget5 this leaves at least one free tip for each clause gadget, and so all the core elements of the clause gadgets get covered as well. /he problem is that /e havent covered all the tips. We started with n Q =k G =nk tips5 the triples Lti6 M covered nk of them5 and the clause gadgets covered an additional k of them. /his leaves n P 3!k tips left to be covered. We handle this problem with a very simple trick( we add n P 3!k &cleanup gadgets' to the construction. +leanup gadget i consists of two core elements = i i G L0i , 0 M, and there is a triple 0i , 0i , b! for every tip b in every variable gadget. /his is the nal piece of the construction. /hus, if the set of clauses has a satisfying assignment, then we make the corresponding choices of odd<even for each variable gadget5 as before, this leaves at least one free tip for each clause gadget. Using the cleanup gadgets to cover the remaining tips, we see that all core elements in the variable, clause, and cleanup gadgets have been covered, and all tips have been covered as well. +onversely, suppose there is a perfect three-dimensional matching in the instance we have constructed. /hen, as we argued above, in each variable gadget the matching chooses either all the even Lti6 M or all the odd Lti6 M. )n the former case, we set xi G K in the >-0*/ instance5 and in the latter case, we set xi G 3. -ow consider clause "6 5 has it been satised9 #ecause the two core elements in P6 have been covered, at least one of the three variable gadgets corresponding to a term in "6 made the &correct' odd<even decision, and this induces a variable assignment that satises "6 . /his concludes the proof, e"cept for one last thing to worry about( 8ave we really constructed an instance of >-2imensional ;atching9 We have a collection of elements, and triples containing certain of them, but can the elements really be partitioned into appropriate sets X , Y , and 7 of e$ual

si e9

,.B Draph +oloring

!!9

1ortunately, the answer is yes. We can dene X to be set of all ai6 with 6 even, the set of all p6 , and the set of all 0i . We can dene Y to be set of all ai6 with 6 odd, the set of all p 6, and the set of all 0 i. 1inally, we can dene 7 to be the set of all tips bi6 . )t is now easy to check that each triple consists of one element from each of X , Y , and 7 .

,.B Draph +oloring


When you color a map 6say, the states in a U.0. map or the countries on a globe7, the goal is to give neighboring regions different colors so that you can see their common borders clearly while minimi ing visual distraction by using only a few colors. )n the middle of the 3Nth century, 1rancis Duthrie noticed that you could color a map of the counties of Hngland this way with only four colors, and he wondered whether the same was true for every map. 8e asked his brother, who relayed the $uestion to one of his professors, and thus a famous mathematical problem was born( the >our-"olor "on6ecture .

$%e Grap% Co oring 'ro( e)


'raph coloring refers to the same process on an undirected graph ', with the nodes playing the role of the regions to be colored, and the edges representing pairs that are neighbors. We seek to assign a color to each node of ' so that if u , v! is an edge, then u and v are assigned different colors5 and the goal is to do this while using a small set of colors. ;ore formally, a kcoloring of ' is a function f ( ( R L3, =, . . . , kM so that for every edge u , v!, we have f u! G f v!. 60o the available colors here are named 3, =, . . . , k, and the function f represents our choice of a color for each node.7 )f ' has a k-coloring, then we will say that it is a k-colorable graph . )n contrast with the case of maps in the plane, its clear that theres not some "ed constant k so that every graph has a k-coloring( 1or e"ample, if we take a set of n nodes and join each pair of them by an edge, the resulting graph needs n colors. 8owever, the algorithmic version of the problem is very interesting( 'iven a graph ' and a bound k# does ' have a k-coloring$ We will refer to this as the 'raph "oloring Problem, or as k-"oloring when we wish to emphasi e a particular choice of k. Draph +oloring turns out to be a problem with a wide range of applications. While its not clear theres ever been much genuine demand from cartographers, the problem arises naturally whenever one is trying to allocate resources in the presence of conFicts.

!#"

+hapter ,

-. and +omputational )ntractability

0uppose, for e"ample, that we have a collection of n processes on a system that can run multiple jobs concurrently, but certain pairs of jobs cannot be scheduled at the same time because they both need a particular resource. %ver the ne"t k time steps of the system, wed like to schedule each process to run in at least one of them. )s this possible9 )f we construct a graph ' on the set of processes, joining two by an edge if they have a conFict, then a k-coloring of ' represents a conFict-free schedule of the processes( all nodes colored 6 can be scheduled in step 6 , and there will never be contention for any of the resources. *nother well-known application arises in the design of compilers. 0uppose we are compiling a program and are trying to assign each variable to one of k registers. )f two variables are in use at a common point in time, then they cannot be assigned to the same register. 6%therwise one would end up overwriting the other.7 /hus we can build a graph ' on the set of variables, joining two by an edge if they are both in use at the same time. -ow a k-coloring of ' corresponds to a safe way of allocating variables to registers( *ll nodes colored 6 can be assigned to register 6 , since no two of them are in use at the same time. * third application arises in wavelength assignment for wireless communication devices( Wed like to assign one of k transmitting wavelengths to each of n devices5 but if two devices are sufciently close to each other, then they need to be assigned different wavelengths to prevent interference. /o deal with this, we build a graph ' on the set of devices, joining two nodes if theyre close enough to interfere with each other5 a k-coloring of this graph is now an assignment of wavelengths so that any nodes assigned the same wavelength are far enough apart that in- terference wont be a problem. 6)nterestingly, this is an application of graph coloring where the &colors' being assigned to nodes are positions on the electromagnetic spectrum!in other words, under a slightly liberal interpretation, theyre actually colors.7

$%e Co)putationa Co)p exit, o- Grap% Co oring


What is the comple"ity of k-+oloring9 1irst of all, the case k G = is a problem weve already seen in +hapter >. 4ecall, there, that we considered the problem of determining whether a graph ' is bipartite, and we showed that this is e$uivalent to the following $uestion( +an one color the nodes of ' red and blue so that every edge has one red end and one blue end9 #ut this latter $uestion is precisely the Draph +oloring .roblem in the case when there are k G = colors 6i.e., red and blue7 available. /hus we have argued that

,.B Draph +oloring

!#1

6,.=37

3 graph ' is =-colorable if and only if it is bipartite.

/his means we can use the algorithm from 0ection >.? to decide whether an input graph ' is =-colorable in + m O n! time, where n is the number of nodes of ' and m is the number of edges. *s soon as we move up to k G > colors, things become much harder. -o simple efcient algorithm for the >-+oloring .roblem suggests itself, as it did for =-+oloring, and it is also a very difcult problem to reason about. 1or e"ample, one might initially suspect that any graph that is not >-colorable will contain a &proof' in the form of four nodes that are all mutually adjacent 6and hence would need four different colors7!but this is not true. /he graph in 1igure ,.3K, for instance, is not >-colorable for a somewhat more subtle 6though still e"plainable7 reason, and it is possible to draw much more complicated graphs that are not >-colorable for reasons that seem very hard to state succinctly. )n fact, the case of three colors is already a very hard problem, as we show now.

Figure 8.1G A graph that is not >0colora+le.

'roving #&Co oring Is 0'&Co)p ete


6,.==7 >-+oloring is NP-complete.

.roof. )t is easy to see why the problem is in -.. Diven ' and k, one certicate that the answer is yes is simply a k-coloring( %ne can verify in polynomial time that at most k colors are used, and that no pair of nodes joined by an edge receive the same color. Cike the other problems in this section, >-+oloring is a problem that is hard to relate at a supercial level to other -.-complete problems weve seen. 0o once again, were going to reach all the way back to >-0*/. Diven an arbitrary instance of >-0*/, with variables x3, . . . , xn and clauses "3, . . . , "k , we will solve it using a black bo" for >-+oloring. /he beginning of the reduction is $uite intuitive. .erhaps the main power of >-+oloring for encoding #oolean e"pressions lies in the fact that we can associate graph nodes with particular terms, and by joining them with edges we ensure that they get different colors5 this can be used to set one true and the other false. 0o with this in mind, we dene nodes vi and vi corresponding to each variable xi and its negation xi . We also dene three &special nodes' - , > , and 1, which we refer to as -rue , >alse , and 1ase . /o begin, we join each pair of nodes vi , vi to each other by an edge, and we join both these nodes to 1ase . 6/his forms a triangle on vi , vi , and 1ase , for each i.7 We also join -rue , >alse , and 1ase into a triangle. /he simple graph

-rue -

>alse >

1ase

v3

? v3

v>

? v>

v=

?v

Figure 8.11 /he +eginning o' the reduction 'or 30)oloring.

' we have dened thus far is pictured in 1igure ,.33, and it already has some useful properties.
.

)n any >-coloring of ', the nodes vi and vi must get different colors, and both must be different from 1ase . )n any >-coloring of ' , the nodes -rue , >alse , and 1ase must get all three colors in some permutation. /hus we can refer to the three colors as the -rue color, the >alse color, and the 1ase color, based on which of these three nodes gets which color. )n particular, this means that for each i, one of vi or vi gets the -rue color, and the other gets the >alse color. 1or the remainder of the construction, we will consider the variable xi to be set to 3 in the given instance of >-0*/ if and only if the node vi gets assigned the -rue color.

0o in summary, we now have a graph ' in which any >-coloring implicitly determines a truth assignment for the variables in the >-0*/ instance. We now need to grow ' so that only satisfying assignments can be e"tended to >-colorings of the full graph. 8ow should we do this9 *s in other >-0*/ reductions, lets consider a clause like x3 , x= , x>. )n the language of >-colorings of ', it says, &*t least one of the nodes v3, v=, or v> should get the -rue color.' 0o what we need is a little subgraph that we can plug into ' , so that any >-coloring that e"tends into this subgraph must have the property of assigning the -rue color to at least one of v3, v=, or v>. )t takes some e"perimentation to nd such a subgraph, but one that works is depicted in 1igure ,.3=.

/he top node can only be colored if one of v3, v? = , or v does not get the >alse color.

>

? v=

v3

v>

>

Figure 8.1& Attaching a su+graph to represent the clause x3 , x= , x>.

/his si"-node subgraph &attaches' to the rest of ' at ve e"isting nodes( -rue , >alse , and those corresponding to the three terms in the clause that were trying to represent 6in this case, v3, v=, and v>.7 -ow suppose that in some >coloring of ' all three of v3, v=, and v> are assigned the >alse color. /hen the lowest two shaded nodes in the subgraph must receive the 1ase color, the three shaded nodes above them must receive, respectively, the >alse , 1ase , and -rue colors, and hence theres no color that can be assigned to the topmost shaded node. )n other words, a >-coloring in which none of v3, v=, or v> is assigned the -rue color cannot be e"tended to a >-coloring of this subgraph.= 1inally, and conversely, some hand-checking of cases shows that as long as one of v3, v=, or v> is assigned the -rue color, the full subgraph can be >-colored. 0o from this, we can complete the construction( We start with the graph ' dened above, and for each clause in the >-0*/ instance, we attach a si"node subgraph as shown in 1igure ,.3=. Cet us call the resulting graph ' .

/his argument actuall7 gives considera+le insight into how one comes up with this su+graph in the 5rst place. /he goal is to have a node liHe the topmost one that cannot receive an7 color. (o we start +7 8plugging in9 three nodes corresponding to the terms, all colored False, at the +ottom. For each one, we then worH upward, pairing it oI with a node o' a Hnown color to 'orce the node a+ove to have the third color. *roceeding in this wa7, we can arrive at a node that is 'orced to have an7 color we want. (o we 'orce each o' the three diIerent colors, starting 'rom each o' the three diIerent terms, and then we plug all three o' these diIerentl7 colored nodes into our topmost node, arriving at the impossi+ilit7.

We now claim that the given >-0*/ instance is satisable if and only if ' has a >-coloring. 1irst, suppose that there is a satisfying assignment for the >-0*/ instance. We dene a coloring of ' by rst coloring 1ase , -rue , and >alse arbitrarily with the three colors, then, for each i, assigning vi the -rue color if xi G 3 and the >alse color if xi G K. We then assign vi the only available color. 1inally, as argued above, it is now possible to e"tend this >coloring into each si"-node clause subgraph, resulting in a >-coloring of all of '. +onversely, suppose ' has a >-coloring. )n this coloring, each node vi is assigned either the -rue color or the >alse color5 we set the variable xi correspondingly. -ow we claim that in each clause of the >-0*/ instance, at least one of the terms in the clause has the truth value 3. 1or if not, then all three of the corresponding nodes has the >alse color in the >-coloring of with this!a contradiction. ' and, ph as consistent we have seen above, there is no >-coloring of the corresponding clause subgra When k @ >, it is very easy to reduce the >-+oloring .roblem to k-+oloring. Hssentially, all we do is to take an instance of >-+oloring, represented by a graph ', add k P > new nodes, and join these new nodes to each other and to every node in '. /he resulting graph is k-colorable if and only if the original graph ' is >-colorable. /hus k-+oloring for any k @ > is -.-complete as well.

Coda: $%e Reso ution o- t%e Four&Co or Con5ecture


/o conclude this section, we should nish off the story of the 1our-+olor +onjecture for maps in the plane as well. *fter more than a hundred years, the conjecture was nally proved by *ppel and 8aken in 3NBA. /he structure of the proof was a simple induction on the number of regions, but the induction step involved nearly two thousand fairly complicated cases, and the verication of these cases had to be carried out by a computer. /his was not a satisfying outcome for most mathematicians( 8oping for a proof that would yield some insight into why the result was true, they instead got a case analysis of enormous comple"ity whose proof could not be checked by hand. /he problem of nding a reasonably short, human-readable proof still remains open.

,., -umerical .roblems


We now consider some computationally hard problems that involve arithmetic operations on numbers. We will see that the intractability here comes from the way in which some of the problems we have seen earlier in the chapter can be encoded in the representations of very large integers.

,., -umerical .roblems

!#*

$%e Su(set Su) 'ro( e)


%ur basic problem in this genre will be %ubset %um, a special case of the Snapsack .roblem that we saw before in 0ection A.? when we covered dynamic programming. We can formulate a decision version of this problem as follows. 'iven natural numbers /3, . . . , /n # and a target number A # is there a subset of L/3, . . . , /n M that adds up to precisely A $ We have already seen an algorithm to solve this problem5 why are we now including it on our list of computationally hard problems9 /his goes back to an issue that we raised the rst time we considered 0ubset 0um in 0ection A.?. /he algorithm we developed there has running time + nA !, which is reasonable when A is small, but becomes hopelessly impractical as A 6and the numbers /i 7 grow large. +onsider, for e"ample, an instance with 3KK numbers, each of which is 3KK bits long. /hen the input is only 3KK T 3KK G 3K,KKK digits, but A is now roughly =3KK. /o phrase this more generally, since integers will typically be given in bit representation, or base-3K representation, the $uantity A is really exponential in the si e of the input5 our algorithm was not a polynomial-time algorithm. 6We referred to it as pseudo-polynomial, to indicate that it ran in time polynomial in the magnitude of the input numbers, but not polynomial in the si e of their representation.7 /his is an issue that comes up in many settings5 for e"ample, we encountered it in the conte"t of network Fow algorithms, where the capacities had integer values. %ther settings may be familiar to you as well. 1or e"ample, the security of a cryptosystem such as 40* is motivated by the sense that factoring a 3,KKK-bit number is difcult. #ut if we considered a running time of =3KKK steps feasible, factoring such a number would not be difcult at all. )t is worth pausing here for a moment and asking( )s this notion of polynomial time for numerical operations too severe a restriction9 1or e"ample, given two natural numbers /3 and /= represented in base-d notation for some d @ 3, how long does it take to add, subtract, or multiply them9 /his is an issue we touched on in 0ection @.@, where we noted that the standard ways that kids in elementary school learn to perform these operations have 6lowdegree7 polynomial running times. *ddition and subtraction 6with carries7 take + log /3 O log /=! time, while the standard multiplication algorithm runs in + log /3 Q log /=! time. 64ecall that in 0ection @.@ we discussed the design of an asymptotically faster multiplication algorithm that elementary schoolchildren are unlikely to invent on their own.7 0o a basic $uestion is( +an 0ubset 0um be solved by a 6genuinely7 polynomial-time algorithm9 )n other words, could there be an algorithm with running time polynomial in n and log A 9 %r polynomial in n alone9

!#6

+hapter ,

-. and +omputational )ntractability

'roving Su(set Su) Is 0'&Co)p ete


/he following result suggests that this is not likely to be the case. 6,.=>7 0ubset 0um is NP-complete. -.. Diven natural numbers there is a solution would be up to A . )n polynomial time, verify that it is e$ual to A .

.roof. We rst show that 0ubset 0um is in /3, . . . , /n , and a target A , a certicate that the subset /i3 , . . . , /ik that is purported to add we can compute the sum of these numbers and

We now reduce a known -.-complete problem to 0ubset 0um. 0ince we are seeking a set that adds up to exactly a given $uantity 6as opposed to being bounded above or below by this $uantity7, we look for a combinatorial problem that is based on meeting an exact bound. /he >-2imensional ;atching .roblem is a natural choice5 we show that >-2imensional ;atching P 0ubset 0um. /he trick will be to encode the manipulation of sets via the addition of integers. 0o consider an instance of >-2imensional ;atching specied by sets X , Y , 7 , each of si e n, and a set of m triples - ! X A Y A 7 . * common way to represent sets is via bit-vectors( Hach entry in the vector corresponds to a different element, and it holds a 3 if and only if the set contains that element. We adopt this type of approach for representing each triple t xi , y6 , *k ! $ - ( we construct a number /t with >n digits that has a 3 in positions i, n ; 6 , and =n ; k, and a K in all other positions. )n other words, for some base d @ 3, /t d i %3 ; d n ;6 %3 ; d=n;k%3. -ote how taking the union of triples almost corresponds to integer addition( /he 3s ll in the places where there is an element in any of the sets. #ut we say almost because addition includes carries( too many 3s in the same column will &roll over' and produce a non ero entry in the ne"t column. /his has no analogue in the conte"t of the union operation. )n the present situation, we handle this problem by a simple trick. We have only m numbers in all, and each has digits e$ual to K or 35 so if we assume that our numbers are written in base d m ; 3, then there will be no carries at all. /hus we construct the following instance of 0ubset 0um. 1or each triple t xi , y6 , *k ! $ - , we construct a number /t in base m ; 3 as dened above. We dene A to be the number in base m ; 3 with >n digits, each of ;>n%3 m 3!i . which is e$ual to 3, that is, i A K We claim that the set - of triples contains a perfect three-dimensional

,., -umerical .roblems

matching if and only if there is a subset of the numbers "/t # that adds up to A . 1or suppose there is a perfect three-dimensional matching consisting of

!#7

!#8

+hapter ,

-. and +omputational )ntractability

triples t3, . . . , tn . /hen in the sum /t3 O . . . O /t , there is a single 3 in each n of the >n digit positions, and so the result is e$ual to A . +onversely, suppose there e"ists a set of numbers /t3 , . . . , /tk that adds up to A . /hen since each /ti has three 3s in its representation, and there are no carries, we know that k G n. )t follows that for each of the >n digit positions, e"actly one of the /ti has a 3 in that position. /hus, t3, . . . , tk constitute a perfect three-dimensional matching.

.xtensions: $%e 3ardness o- Certain Sc%edu ing 'ro( e)s


/he hardness of 0ubset 0um can be used to establish the hardness of a range of scheduling problems!including some that do not obviously involve the addition of numbers. 8ere is a nice e"ample, a natural 6but much harder7 generali ation of a scheduling problem we solved in 0ection ?.= using a greedy algorithm. 0uppose we are given a set of n jobs that must be run on a single machine. Hach job i has a release time ri when it is rst available for processing5 a deadline di by which it must be completed5 and a processing duration ti . We will assume that all of these parameters are natural numbers. )n order to be completed, job i must be allocated a contiguous slot of ti time units somewhere in the interval Uri , di V. /he machine can run only one job at a time. /he $uestion is( +an we schedule all jobs so that each completes by its deadline9 We will call this an instance of %cheduling /ith Belease -imes and 8eadlines. 6,.=?7 0cheduling with 4elease /imes and 2eadlines is NP-complete.

.roof. Diven an instance of the problem, a certicate that it is solvable would be a specication of the starting time for each job. We could then check that each job runs for a distinct interval of time, between its release time and deadline. /hus the problem is in -.. We now show that 0ubset 0um is reducible to this scheduling problem. /hus, consider an instance of 0ubset 0um with numbers /3, . . . , /n and a target A . )n constructing an e$uivalent scheduling instance, one is struck initially by the fact that we have so many parameters to manage( release times, deadlines, and durations. /he key is to sacrice most of this Fe"ibility, producing a &skeletal' instance of the problem that still encodes the 0ubset 0um .roblem. G /i . We dene jobs 3, =, . . . , n5 job i has a release time of n iG3 Cet % K, a deadline of % O 3, and a duration of /i . 1or this set of jobs, we have the freedom to arrange them in any order, and they will all nish on time.

We now further constrain the instance so that the only way to solve it will be to group together a subset of the jobs whose durations add up precisely to A . /o do this, we dene an n O 3!st job5 it has a release time of A , a deadline of A O 3, and a duration of 3. -ow consider any feasible solution to this instance of the scheduling problem. /he n O 3!st job must be run in the interval UA , A O 3V. /his leaves % available time units between the common release time and the common deadline5 and there are % time units worth of jobs to run. /hus the machine must not have any idle time, when no jobs are running. )n particular, if jobs i3, . . . , ik are the ones that run before time A , then the corresponding numbers /i3 , . . . , /ik in the 0ubset 0um instance add up to e"actly A . +onversely, if there are numbers /i3 , . . . , /ik that add up to e"actly A , solution to the scheduling then we feasible can schedule these before job n O instance. 3 and the remainder after job n O 35 this is a

Caveat: Su(set Su) 2it% 'o ,no)ia , 6ounded 0u)(ers


/here is a very common source of pitfalls involving the 0ubset 0um .roblem, and while it is closely connected to the issues we have been discussing already, we feel it is worth discussing e"plicitly. /he pitfall is the following. "onsider the special case of %ubset %um# /ith n input numbers# in /hich A is bounded by a polynomial function of n. 3ssuming . G -.# this special case is not NP-complete. )t is not -.-complete for the simple reason that it can be solved in time + nA !, by our dynamic programming algorithm from 0ection A.?5 when A is bounded by a polynomial function of n, this is a polynomial-time algorithm. *ll this is very clear5 so you may ask( Why dwell on it9 /he reason is that there is a genre of problem that is often wrongly claimed to be -.-complete 6even in published papers7 via reduction from this special case of 0ubset 0um. 8ere is a basic e"ample of such a problem, which we will call "omponent 'rouping . 'iven a graph ' that is not connected# and a number k# does there exist a subset of its connected components /hose union has si*e exactly k$ )ncorrect +laim. +omponent Drouping is -.-complete. )ncorrect .roof. +omponent Drouping is in -., and well skip the proof of this. We now attempt to show that 0ubset 0um :P +omponent Drouping. Diven an instance of 0ubset 0um with numbers /3, . . . , /n and target A , we construct an instance of +omponent Drouping as follows. 1or each i, we construct a path Pi of length /i . /he graph ' will be the union of the paths

,.N +o--. and the *symmetry of -.

!#9

P3, . . . , Pn , each of which is a separate connected component. We set k G A . )t is clear that ' has a set of connected components whose union has si e k if and only if some subset of the numbers / 3 , . . . , / n adds up to A . /he error here is subtle5 in particular, the claim in the last sentence is correct. /he problem is that the construction described above does not establish that 0ubset 0um :P +omponent Drouping, because it re$uires more than polynomial time. )n constructing the input to our black bo" that solves +omponent Drouping, we had to build the encoding of a graph of si e /3 O . . . O /n , and this takes time e"ponential in the si e of the input to the 0ubset 0um instance. )n effect, 0ubset 0um works with the numbers /3, . . . , /n in a very compact representation, but +omponent Drouping does not accept &compact' encodings of graphs. /he problem is more fundamental than the incorrectness of this proof5 in fact, +omponent Drouping is a problem that can be solved in polynomial time. )f n3, n= , . . . , nc denote the si es of the connected components of ' , we simply use our dynamic programming algorithm for 0ubset 0um to decide whether some subset of these numbers Lni M adds up to k. /he running time re$uired for this is + ck!5 and since c and k are both bounded by n, this is + n=! time. /hus we have discovered a new polynomial-time algorithm by reducing in the other direction, to a polynomial-time solvable special case of 0ubset 0um.

,.N +o--. and the *symmetry of -.


*s a further perspective on this general class of problems, lets return to the denitions underlying the class -.. Weve seen that the notion of an efcient certier doesnt suggest a concrete algorithm for actually solving the problem thats better than brute-force search. -ow heres another observation( /he denition of efcient certication, and hence of -., is fundamentally asymmetric . *n input string s is a &yes' instance if and only if there e"ists a short t so that 1 s , t! G yes. -egating this statement, we see that an input string s is a &no' instance if and only if for all short t , its the case that 1 s , t! G no. /his relates closely to our intuition about -.( When we have a &yes' instance, we can provide a short proof of this fact. #ut when we have a &no' instance, no correspondingly short proof is guaranteed by the denition5 the answer is no simply because there is no string that will serve as a proof. )n concrete terms, recall our $uestion from 0ection ,.>( Diven an unsatisable set of clauses, what evidence could we show to $uickly convince you that there is no satisfying assignment9

!1"

+hapter ,

-. and +omputational )ntractability

1or every problem X , there is a natural complementary problem X ( 1or all input strings s, we say s $ X if and only if s $ X . -ote that if X $ ., then X $ ., since from an algorithm 3 that solves X , we can simply produce an algorithm 3 that runs 3 and then Fips its answer. #ut it is far from clear that if X $ -., it should follow that X $ -.. /he problem X , rather, has a different property( for all s, we have s $ X if and only if for all t of length at most p 2s2!, 1 s , t! no. /his is a fundamentally different denition, and it cant be worked around by simply &inverting' the output of the efcient certier 1 to produce 1. /he problem is that the &e"ists t ' in the denition of -. has become a &for all t ,' and this is a serious change. /here is a class of problems parallel to -. that is designed to model this issue5 it is called, naturally enough, co--.. * problem X belongs to co--. if and only if the complementary problem X belongs to -.. We do not know for sure that -. and co--. are different5 we can only ask 6,.=@7 8oes -. co--.$

*gain, the widespread belief is that -. co--.( Just because the &yes' instances of a problem have short proofs, it is not clear why we should believe that the &no' instances have short proofs as well. .roving -. co--. would be an even bigger step than proving . -., for the following reason( 6,.=A7 -. . .roof. Well actually prove the contrapositive statement( . -. implies -. co--.. Hssentially, the point is that . is closed under complementation5 so if . -., then -. would be closed under complementation as well. ;ore formally, starting from the assumption . -., we have X $ -. J X $ . J X $ . J X $ -. J X $ co--. and X $ co--. J X $ -. J X $ . J X $ . J X $ -.. 8ence it would follow that -. ! co--. and co--. ! -., whence -. co--.. &f -. co--.# then .

Good C%aracteri7ations: $%e C ass 0' K co&0'


)f a problem X belongs to both -. and co--., then it has the following nice property( When the answer is yes, there is a short proof5 and when the answer is no, there is also a short proof. /hus problems that belong to this intersection

,.3K * .artial /a"onomy of 8ard .roblems

!11

-. K co--. are said to have a good characteri*ation, since there is always a nice certicate for the solution. /his notion corresponds directly to some of the results we have seen earlier. 1or e"ample, consider the problem of determining whether a Fow network contains a Fow of value at least 2 , for some $uantity 2 . /o prove that the answer is yes, we could simply e"hibit a Fow that achieves this value5 this is consistent with the problem belonging to -.. #ut we can also prove the answer is no( We can e"hibit a cut whose capacity is strictly less than 2 . /his duality between &yes' and &no' instances is the cru" of the ;a"-1low ;in-+ut /heorem. 0imilarly, 8alls /heorem for matchings from 0ection B.@ proved that the #ipartite .erfect ;atching .roblem is in -. K co--.( We can e"hibit either a perfect matching, or a set of vertices 3 ! X such that the total number of neighbors of 3 is strictly less than 232. -ow, if a problem X is in ., then it belongs to both -. and co--.5 thus, . ! -. K co--.. )nterestingly, both our proof of the ;a"-1low ;in-+ut /heorem and our proof of 8alls /heorem came hand in hand with proofs of the stronger results that ;a"imum 1low and #ipartite ;atching are problems in .. -evertheless, the good characteri ations themselves are so clean that formulating them separately still gives us a lot of conceptual leverage in reasoning about these problems. -aturally, one would like to know whether theres a problem that has a good characteri ation but no polynomial-time algorithm. #ut this too is an open $uestion( 6,.=B7 8oes . -. K co--.$ 6,.=@7, general opinion seems somewhat is because there are many cases in which nontrivial good characteri ation5 and then was also discovered to have a polynomial-

Unlike $uestions 6,.337 and mi"ed on this one. )n part, this a problem was found to have a 6sometimes many years later7 it time algorithm.

,.3K * .roblems

.artial

/a"onomy

of

8ard

Weve now reached the end of the chapter, and weve encountered a fairly rich array of -.-complete problems. )n a way, its useful to know a good number of different -.-complete problems( When you encounter a new problem X and want to try proving its -.-complete, you want to show Y P X for some known -.-complete problem Y !so the more options you have for Y , the better.

!1!

+hapter ,

-. and +omputational )ntractability

*t the same time, the more options you have for Y , the more bewildering it can be to try choosing the right one to use in a particular reduction. %f course, the whole point of -.-completeness is that one of these problems will work in your reduction if and only if any of them will 6since theyre all e$uivalent with respect to polynomial-time reductions75 but the reduction to a given problem X can be much, much easier starting from some problems than from others. With this in mind, we spend this concluding section on a review of the -.complete problems weve come across in the chapter, grouped into si" basic genres. /ogether with this grouping, we offer some suggestions as to how to choose a starting problem for use in a reduction.

'ac8ing 'ro( e)s


.acking problems tend to have the following structure( Ioure given a collection of objects, and you want to choose at least k of them5 making your life difcult is a set of conFicts among the objects, preventing you from choosing certain groups simultaneously. Weve seen two basic packing problems in this chapter.
.

&ndependent %et ( Diven a graph ' and a number k, does ' contain an independent set of si e at least k9 %et Packing ( Diven a set . of n elements, a collection %3, . . . , %m of subsets of . , and a number k, does there e"ist a collection of at least k of these sets with the property that no two of them intersect9

Covering 'ro( e)s


+overing problems form a natural contrast to packing problems, and one typically recogni es them as having the following structure( youre given a collection of objects, and you want to choose a subset that collectively achieves a certain goal5 the challenge is to achieve this goal while choosing only k of the objects. Weve seen two basic covering problems in this chapter.
.

(ertex "over ( Diven a graph ' and a number k, does ' contain a verte" cover of si e at most k9 %et "over ( Diven a set . of n elements, a collection %3, . . . , %m of subsets of . , and a number k, does there e"ist a collection of at most k of these sets whose union is e$ual to all of . 9

'artitioning 'ro( e)s


.artitioning problems involve a search over all ways to divide up a collection of objects into subsets so that each object appears in e"actly one of the subsets.

,.3K * .artial /a"onomy of 8ard .roblems

!1#

%ne of our two basic partitioning problems, >-2imensional ;atching, arises naturally whenever you have a collection of sets and you want to solve a covering problem and a packing problem simultaneously( +hoose some of the sets in such a way that they are disjoint, yet completely cover the ground set.
.

4-8imensional <atching ( Diven disjoint sets X , Y , and 7 , each of si e n, and given a set - ! X A Y A 7 of ordered triples, does there e"ist a set of n triples in - so that each element of X B Y B 7 is contained in e"actly one of these triples9

%ur other basic partitioning problem, Draph +oloring, is at work whenever youre seeking to partition objects in the presence of conFicts, and conFicting objects arent allowed to go into the same set.
.

'raph "oloring ( Diven a graph ' and a bound k, does ' have a k-coloring9

Se9uencing 'ro( e)s


%ur rst three types of problems have involved searching over subsets of a collection of objects. *nother type of computationally hard problem involves searching over the set of all permutations of a collection of objects. /wo of our basic se$uencing problems draw their difculty from the fact that you are re$uired to order n objects, but there are restrictions preventing you from placing certain objects after certain others.
.

;amiltonian "ycle ( Diven a directed graph ' , does it contain a 8amiltonian cycle9 ;amiltonian Path( Diven a directed graph ', does it contain a 8amiltonian path9

%ur third basic se$uencing problem is very similar5 it softens these restrictions by simply imposing a cost for placing one object after another.
.

-raveling %alesman( Diven a set of distances on n cities, and a bound 8, is there a tour of length at most 89

0u)erica 'ro( e)s


/he hardness of the numerical problems considered in this chapter Fowed principally from 0ubset 0um, the special case of the Snapsack .roblem that we considered in 0ection ,.,.
.

%ubset %um( Diven natural numbers /3, . . . , /n , and a target number A , is there a subset of "/3, . . . , /n # that adds up to precisely A 9

)t is natural to try reducing from %ubset %um whenever one has a problem with weighted objects and the goal is to select objects conditioned on a constraint on

!11 !11

+hapter ,

-. and +omputational )ntractability

the total weight of the objects selected. /his, for e"ample, is what happened in the proof of 6,.=?7, showing that 0cheduling with 4elease /imes and 2eadlines is -.-complete. *t the same time, one must heed the warning that 0ubset 0um only becomes hard with truly large integers5 when the magnitudes of the input numbers are bounded by a polynomial function of n, the problem is solvable in polynomial time by dynamic programming.

Constraint Satis-action 'ro( e)s


1inally, we considered basic constraint satisfaction problems, including +ircuit 0atisability, 0*/, and >-0*/. *mong these, the most useful for the purpose of designing reductions is >-0*/.
.

4-%3- ( Diven a set of clauses "3, . . . , "k , each of length >, over a set of variables X "x3, . . . , xn #, does there e"ist a satisfying truth assignment9

#ecause of its e"pressive Fe"ibility, >-0*/ is often a useful starting point for reductions where none of the previous ve categories seem to t naturally onto the problem being considered. )n designing >-0*/ reductions, it helps to recall the advice given in the proof of 6,.,7, that there are two distinct ways to view an instance of >-0*/( 6a7 as a search over assignments to the variables, subject to the constraint that all clauses must be satised, and 6b7 as a search over ways to choose a single term 6to be satised7 from each clause, subject to the constraint that one mustnt choose conFicting terms from different clauses. Hach of these perspectives on >-0*/ is useful, and each forms the key idea behind a large number of reductions.

0olved H"ercises
So ved .xercise 1
Ioure consulting for a small high-tech company that maintains a high-security computer system for some sensitive work that its doing. /o make sure this system is not being used for any illicit purposes, theyve set up some logging software that records the ). addresses that all their users are accessing over time. Well assume that each user accesses at most one ). address in any given minute5 the software writes a log le that records, for each user u and each minute m, a value & u , m! that is e$ual to the ). address 6if any7 accessed by user u during minute m. )t sets & u , m! to the null symbol L if u did not access any ). address during minute m. /he company management just learned that yesterday the system was used to launch a comple" attack on some remote sites. /he attack was carried out by accessing t distinct ). addresses over t consecutive minutes( )n minute

0olved H"ercises

!1* !1*

3, the attack accessed address i35 in minute =, it accessed address i=5 and so on, up to address it in minute t . Who could have been responsible for carrying out this attack9 /he company checks the logs and nds to its surprise that theres no single user u who accessed each of the ). addresses involved at the appropriate time5 in other words, theres no u so that & u , m! im for each minute m from 3 to t . 0o the $uestion becomes( What if there were a small coalition of k users that collectively might have carried out the attack9 We will say a subset % of users is a suspicious coalition if, for each minute m from 3 to t , there is at least one user u $ % for which & u , m! im. 6)n other words, each ). address was accessed at the appropriate time by at least one user in the coalition.7 /he %uspicious "oalition Problem asks( Diven the collection of all values & u , m!, and a number k, is there a suspicious coalition of si e at most k9 Solution 1irst of all, 0uspicious +oalition is clearly in -.( )f we were to be shown a set % of users, we could check that % has si e at most k, and that for each minute m from 3 to t , at least one of the users in % accessed the ). address im . -ow we want to nd a known -.-complete problem and reduce it to 0uspicious +oalition. *lthough 0uspicious +oalition has lots of features 6users, minutes, ). addresses7, its very clearly a covering problem 6following the ta"onomy described in the chapter7( We need to e"plain all t suspicious accesses, and were allowed a limited number of users 6k7 with which to do this. %nce weve decided its a covering problem, its natural to try reducing Eerte" +over or 0et +over to it. *nd in order to do this, its useful to push most of its complicated features into the background, leaving just the bare-bones features that will be used to encode Eerte" +over or 0et +over. Cets focus on reducing Eerte" +over to it. )n Eerte" +over, we need to cover every edge, and were only allowed k nodes. )n 0uspicious +oalition, we need to &cover' all the accesses, and were only allowed k users. /his parallelism strongly suggests that, given an instance of Eerte" +over consisting of a graph ' ( , )! and a bound k, we should construct an instance of 0uspicious +oalition in which the users represent the nodes of ' and the suspicious accesses represent the edges. 0o suppose the graph ' for the Eerte" +over instance has m edges e3, . . . , em , and e6 v6 , /6 !. We construct an instance of 0uspicious +oali- tion as follows. 1or each node of ' we construct a user, and for each edge et vt , /t ! we construct a minute t . 60o there will be m minutes total.7 )n minute t , the users associated with the two ends of et access an ). address it , and all other users access nothing. 1inally, the attack consists of accesses to addresses i3, i= , . . . , im in minutes 3, =, . . . , m , respectively.

!16 !16

+hapter ,

-. and +omputational )ntractability

/he following claim will establish that Eerte" +over :P 0uspicious +oalition and hence will conclude the proof that 0uspicious +oalition is -.complete. Diven how closely our construction of the instance shadows the original Eerte" +over instance, the proof is completely straightforward. 6,.=,7 &n the instance constructed# there is a suspicious coalition of si*e at most k if and only if the graph ' contains a vertex cover of si*e at most k. .roof. 1irst, suppose that ' contains a verte" cover " of si e at most k. /hen consider the corresponding set % of users in the instance of 0uspicious +oalition. 1or each t from 3 to m, at least one element of " is an end of the edge et , and the corresponding user in % accessed the ). address it . 8ence the set % is a suspicious coalition. +onversely, suppose that there is a suspicious coalition % of si e at most k, and consider the corresponding set of nodes " in '. 1or each t from 3 to m, at least one user in % accessed the ). address it , and the corresponding node in " is an end of the edge et . 8ence the set " is a verte" cover.

So ved .xercise !
Iouve been asked to organi e a freshman-level seminar that will meet once a week during the ne"t semester. /he plan is to have the rst portion of the semester consist of a se$uence of guest lectures by outside speakers, and have the second portion of the semester devoted to a se$uence of p hands-on projects that the students will do. /here are n options for speakers overall, and in week number i 6for i G 3, =, . . . , 7 a subset ,i of these speakers is available to give a lecture. %n the other hand, each project re$uires that the students have seen certain background material in order for them to be able to complete the project successfully. )n particular, for each project 6 6for 6 G 3, =, . . . , p7, there is a subset P6 of relevant speakers so that the students need to have seen a lecture by at least one of the speakers in the set P6 in order to be able to complete the project. 0o this is the problem( Diven these sets, can you select e"actly one speaker for each of the rst weeks of the seminar, so that you only choose speakers who are available in their designated week, and so that for each project 6 , the students will have seen at least one of the speakers in the relevant set P6 9 Well call this the ,ecture Planning Problem. /o make this clear, lets consider the following sample instance. 0uppose that G =, p G >, and there are n G ? speakers that we denote 3, 1 , " , 8. /he availability of the speakers is given by the sets ,3 G L3, 1 , " M and ,= G L3, 8M. /he relevant speakers for each project are given by the sets P3 G L1 , " M,

0olved H"ercises

!17 !17

P= G L3, 1 , 8M, and P> G L" , 8M. problem is yes, since we can choose 8 in the second week5 this way, for have seen at least one of the relevant

/hen the answer to this instance of the speaker 1 in the rst week and speaker each of the three projects, students will speakers.

.rove that Cecture .lanning is -.-complete. Solution /he problem is in -. since, given a se$uence of speakers, we can check 6a7 all speakers are available in the weeks when theyre scheduled, and 6b7 that for each project, at least one of the relevant speakers has been scheduled. -ow we need to nd a known -.-complete problem that we can reduce to Cecture .lanning. /his is less clear-cut than in the previous e"ercise, because the statement of the Cecture .lanning .roblem doesnt immediately map into the ta"onomy from the chapter. /here is a useful intuitive view of Cecture .lanning, however, that is characteristic of a wide range of constraint satisfaction problems. /his intuition is captured, in a strikingly pictures$ue way, by a description that appeared in the Ne/ Yorker of the lawyer 2avid #oiess cross-e"amination style( 8uring a cross-examination# 8avid takes a friendly /alk do/n the hall /ith you /hile hes 0uietly closing doors. -hey get to the end of the hall and 8avid turns on you and theres no place to go. ;es closed all the doors.> What does constraint satisfaction have to do with cross-e"amination9 )n Cecture .lanning, as in many similar problems, there are two conceptual phases. /heres a rst phase in which you walk through a set of choices, selecting some and thereby closing the door on others5 this is followed by a second phase in which you nd out whether your choices have left you with a valid solution or not. )n the case of Cecture .lanning, the rst phase consists of choosing a speaker for each week, and the second phase consists of verifying that youve picked a relevant speaker for each project. #ut there are many -.-complete problems that t this description at a high level, and so viewing Cecture .lanning this way helps us search for a plausible reduction. We will in fact describe two reductions, rst from >-0*/ and then from Eerte" +over. %f course, either one of these by itself is enough to prove -.-completeness, but both make for useful e"amples. >-0*/ is the canonical e"ample of a problem with the two-phase structure described above( We rst walk through the variables, setting each one to true or false5 we then look over each clause and see whether our choices

>

Men Auletta Nuoting OeIre7 Plattner, The New Yorker , 1= August 1DDD.

!18 !18

+hapter ,

-. and +omputational )ntractability

have satised it. /his parallel to Cecture .lanning already suggests a natural reduction showing that >-0*/ P Cecture .lanning( We set things up so that the choice of lecturers sets the variables, and then the feasibility of the projects represents the satisfaction of the clauses. ;ore concretely, suppose we are given an instance of >-0*/ consisting of clauses "3, . . . , "k over the variables x3, x= , . . . , xn . We construct an instance of Cecture .lanning as follows. 1or each variable xi , we create two lecturers i *i and * that will correspond to xi and its negation. We begin with n weeks of lectures5 in week i, the only two lecturers available arei *i and * . /hen there is a se$uence of k projects5 for project 6 , the set of relevant lecturers P6 consists of the three lecturers corresponding to the terms in clause "6 . -ow, if there is a satisfying assignment 2 for the >-0*/ instance, i then in week i we choose the lecturer among *i , * that corresponds to the value assigned to xi by 2 5 in this case, we will select at least one speaker from each relevant set P6 . +onversely, if we nd a way to choose speakers so that there is at least one from each relevant set, then we can set the variables xi i as follows( xi is set to 3 if *i is chosen, and it is set to K if * is chosen. )n this way, at least one of the three variables in each clause "6 is set in a way that satises it, and so this is a satisfying assignment. /his concludes the reduction and its proof of correctness. %ur intuitive view of Cecture .lanning leads naturally to a reduction from Eerte" +over as well. 6What we describe here could be easily modied to work from 0et +over or >-2imensional ;atching too.7 /he point is that we can view Eerte" +over as having a similar two-phase structure( We rst choose a set of k nodes from the input graph, and we then verify for each edge that these choices have covered all the edges. Diven an input to Eerte" +over, consisting of a graph ' ( , )! and a number k, we create a lecturer *v for each node v. We set k, and dene ,3 ,= . . . ,k "*v ( v $ ( #. )n other words, for the rst k weeks, all lecturers are available. *fter this, we create a project 6 for each edge e6 v , /!, with set P6 "*v , */ #. -ow, if there is a verte" cover % of at most k nodes, then consider the set of lecturers 7% "*v ( v $ %#. 1or each project P6 , at least one of the relevant speakers belongs to 7% , since % covers all edges in ' . ;oreover, we can schedule all the lecturers in 7% during the rst k weeks. /hus it follows that there is a feasible solution to the instance of Cecture .lanning. +onversely, suppose there is a feasible solution to the instance of Cecture .lanning, and let - be the set of all lecturers who speak in the rst k weeks. Cet X be the set of nodes in ' that correspond to lecturers in - . 1or each project P6 , at least one of the two relevant speakers appears in - , and hence at least

H"ercises

!19 !19

one end of each edge e6 is in the set X . /hus X is a verte" cover with at most k nodes. /his concludes the proof that Eerte" +over :P Cecture .lanning.

H"ercises
1. For each o' the two Nuestions +elow, decide whether the answer is QiR 8Ses,9 QiiR 8To,9 or QiiiR 8UnHnown, +ecause it would resolve the Nuestion o' whether . G -. .9 Vive a +rie' explanation o' 7our answer. QaR WetXs de'ine the decision version o' the 1nterval (cheduling *ro+0 lem 'rom )hapter 4 as 'ollows@ Viven a collection o' intervals on a time0line, and a +ound k, does the collection contain a su+set o' nonoverlapping intervals o' size at least kY Zuestion@ 1s it the case that 1nterval (cheduling :P [ertex )overY Q+R Zuestion@ 1s it the case that 1ndependent (et :P 1nterval (chedulingY &. A store tr7ing to anal7ze the +ehavior o' its customers will o'ten maintain a two0dimensional arra7 3, where the rows correspond to its customers and the columns correspond to the products it sells. /he entr7 3Ui , 6 V speci'ies the Nuantit7 o' product 6 that has +een purchased +7 customer i. >ereXs a tin7 example o' such an arra7 3.

i9uid detergent 4aj *lanis +helsea K = K

(eer A > K

diapers K K K

cat itter > K B

\ne thing that a store might want to do with this data is the 'ollowing. Wet us sa7 that a su+set % o' the customers is diverse i' no two o' the o' the customers in % have ever +ought the same product Qi.e., 'or each product, at most one o' the customers in % has ever +ought itR. A diverse set o' customers can +e use'ul, 'or example, as a target pool 'or marHet research. ]e can now de'ine the Eiverse (u+set *ro+lem as 'ollows@ Viven an m T n arra7 3 as de'ined a+ove, and a num+er k : m, is there a su+set o' at least k o' customers that is diverseY (how that Eiverse (u+set is T*0complete. 3. (uppose 7ouXre helping to organize a summer sports camp, and the 'ollowing pro+lem comes up. /he camp is supposed to have at least

!*" !*"

+hapter ,

-. and +omputational )ntractability

one counselor whoXs sHilled at each o' the n sports covered +7 the camp Q+ase+all, volle7+all, and so onR. /he7 have received ^o+ applications 'rom m potential counselors. For each o' the n sports, there is some su+set o' the m applicants Nuali'ied in that sport. /he Nuestion is@ For a given num+er k C m, is it possi+le to hire at most k o' the counselors and have at least one counselor Nuali'ied in each o' the n sportsY ]eXll call this the Efficient Recruiting Problem. (how that _''icient `ecruiting is T*0complete. 4. (uppose 7ouXre consulting 'or a group that manages a high0 per'ormance real0time s7stem in which as7nchronous processes maHe use o' shared resources. /hus the s7stem has a set o' n processes and a set o' m resources . At an7 given point in time, each process speci'ies a set o' resources that it reNuests to use. _ach resource might +e reNuested +7 man7 processes at once6 +ut it can onl7 +e used +7 a single process at a time. Sour ^o+ is to allocate resources to processes that reNuest them. 1' a process is allocated all the resources it reNuests, then it is active 6 otherwise it is blocked . Sou want to per'orm the allocation so that as man7 processes as possi+le are active. /hus we phrase the Resource Reservation Problem as 'ollows@ Viven a set o' processes and resources, the set o' reNuested resources 'or each process, and a num+er k, is it possi+le to allocate resources to processes so that at least k processes will +e activeY )onsider the 'ollowing list o' pro+lems, and 'or each pro+lem ei0 ther give a pol7nomial0time algorithm or prove that the pro+lem is T*0 complete. QaR /he general `esource `eservation *ro+lem de'ined a+ove. Q+R =. QcR /he special case o' the pro+lem when k /he special case o' the pro+lem when there are two t7pes o' re0 sourcesasa7, people and eNuipmentaand each process reNuires at most one resource o' each t7pe Q1n other words, each process reNuires one speci'ic person and one speci'ic piece o' eNuipment.R /he special case o' the pro+lem when each resource is reNuested +7 at most two processes.

QdR

<. )onsider a set 3 "a3, . . . , an # and a collection 13, 1= , . . . , 1m o' su+sets o' 3 Qi.e., 1i ! 3 'or each iR. ]e sa7 that a set ; ! 3 is a hitting set 'or the collection 13, 1= , . . . , 1m i' ; contains at least one element 'rom each 1i athat is, i' ; K 1i

H"ercises is not empt7 'or each i Qso ; 8hits9 all the sets 1i R.

!*1 !*1

]e now de'ine the Hitting Set Problem as 'ollows. ]e are given a set 3 "a3, . . . , an #, a collection 13, 1= , . . . , 1m o' su+sets o' 3, and a num+er

!*! !*!

+hapter ,

-. and +omputational )ntractability

k. ]e are asHed@ 1s there a hitting set ; ! 3 'or 13, 1= , . . . , 1m so that the size o' ; is at most kY *rove that >itting (et is T*0complete. =. )onsider an instance o' the (atis'ia+ilit7 *ro+lem, speci'ied +7 clauses "3, . . . , "k over a set o' Poolean varia+les x3, . . . , xn . ]e sa7 that the instance is monotone i' each term in each clause consists o' a nonnegated varia+le6 that is, each term is eNual to xi , 'or some i, rather than xi . Fonotone instances o' (atis'ia+ilit7 are ver7 eas7 to solve@ /he7 are alwa7s satis'ia+le, +7 setting each varia+le eNual to 3. For example, suppose we have the three clauses x3 , x=! , x3 , x>! , x= , x>!. /his is monotone, and indeed the assignment that sets all three varia+les to 3 satis'ies all the clauses. Put we can o+serve that this is not the onl7 satis'7ing assignment6 we could also have set x3 and x= to 3, and x> to K. 1ndeed, 'or an7 monotone instance, it is natural to asH how 'ew varia+les we need to set to 3 in order to satis'7 it. Viven a monotone instance o' (atis'ia+ilit7, together with a num+er k, the pro+lem o' onotone Satisfiabilit! with Few True "ariables asHs@ 1s there a satis'7ing assignment 'or the instance in which at most k varia+les are set to 3Y *rove this pro+lem is T*0 complete. ?. (ince the 30Eimensional Fatching *ro+lem is T*0complete, it is natural to expect that the corresponding 40Eimensional Fatching *ro+lem is at least as hard. Wet us de'ine #$%imensional atching as 'ollows. Viven sets A , X , Y , and 7 , each o' size n, and a collection " o' ordered ?0tuples o' the 'orm /i , x6 , yk , * !, do there exist n ?0tuples 'rom " so that no two have an element in commonY *rove that 40Eimensional Fatching is T*0complete. 8. Sour 'riendsX preschool0age daughter Fadison has recentl7 learned to spell some simple words. /o help encourage this, her parents got her a color'ul set o' re'rigerator magnets 'eaturing the letters o' the alpha+et Qsome num+er o' copies o' the letter 3, some num+er o' copies o' the letter 1, and so onR, and the last time 7ou saw her the two o' 7ou spent a while arranging the magnets to spell out words that she Hnows. (omehow with 7ou and Fadison, things alwa7s end up getting more ela+orate than originall7 planned, and soon the two o' 7ou were tr7ing to spell out words so as to use up all the magnets in the 'ull setathat is, picHing words that she Hnows how to spell, so that once the7 were all spelled out, each magnet was participating in the

H"ercises spelling o' exactl7 one

!*# !*#

!*1 !*1

+hapter ,

-. and +omputational )ntractability

o' the words. QFultiple copies o' words are oHa7 here6 so 'or example, i' the set o' re'rigerator magnets includes two copies each o' " , 3, and - , it would +e oHa7 to spell out &'T twice.R /his turned out to +e prett7 di''icult, and it was onl7 later that 7ou realized a plausi+le reason 'or this. (uppose we consider a general version o' the pro+lem o' (sing (p 'll the Refrigerator agnets , where we replace the _nglish alpha+et +7 an ar+itrar7 collection o' s7m+ols, and we model FadisonXs voca+ular7 as an ar+itrar7 set o' strings over this collection o' s7m+ols. /he goal is the same as in the previous paragraph. *rove that the pro+lem o' Using Up All the `e'rigerator Fagnets is T*0 complete. D. )onsider the 'ollowing pro+lem. Sou are managing a communication networH, modeled +7 a directed graph ' G ( , )!. /here are c users who are interested in maHing use o' this networH. User i Q'or each i G 3, =, . . . , c R issues a re)uest to reserve a speci'ic path Pi in ' on which to transmit data. Sou are interested in accepting as man7 o' these path reNuests as possi+le, su+^ect to the 'ollowing restriction@ i' 7ou accept +oth Pi and P6 , then Pi and P6 cannot share an7 nodes. /hus, the Path Selection Problem asHs@ Viven a directed graph ' G ( , )!, a set o' reNuests P3, P= , . . . , Pc aeach o' which must +e a path in ' aand a num+er k, is it possi+le to select at least k o' the paths so that no two o' the selected paths share an7 nodesY *rove that *ath (election is T*0complete. 1G. Sour 'riends at ]e+_xodus have recentl7 +een doing some consulting worH 'or companies that maintain large, pu+licl7 accessi+le ]e+ sitesa contractual issues prevent them 'rom sa7ing which onesaand the7Xve come across the 'ollowing Strategic 'dvertising Problem. A compan7 comes to them with the map o' a ]e+ site, which weXll model as a directed graph ' G ( , )!. /he compan7 also provides a set o' t trails t7picall7 'ollowed +7 users o' the site6 weXll model these trails as directed paths P3, P= , . . . , Pt in the graph ' Qi.e., each Pi is a path in ' R. /he compan7 wants ]e+_xodus to answer the 'ollowing Nuestion 'or them@ Viven ' , the paths LPi M, and a num+er k, is it possi+le to place advertisements on at most k o' the nodes in ' , so that each path Pi includes at least one node containing an advertisementY ]eXll call

H"ercises !** this !** the (trategic Advertising *ro+lem, with input ' , LPi ( i G 3, . . . , t M, and k. Sour 'riends 'igure that a good algorithm 'or this will maHe them all rich6 un'ortunatel7, things are never Nuite this simple.

!*6 !*6
QaR Q+R

+hapter ,

-. and +omputational )ntractability

*rove that (trategic Advertising is T*0complete. Sour 'riends at ]e+_xodus 'orge ahead and write a prett7 'ast algo0 rithm 0 that produces 7esbno answers to ar+itrar7 instances o' the (trategic Advertising *ro+lem. Sou ma7 assume that the algorithm 0 is alwa7s correct. Using the algorithm 0 as a +lacH +ox, design an algorithm that taHes input ' , "Pi #, and k as in part QaR, and does one o' the 'ollowing two things@ c \utputs a set o' at most k nodes in ' so that each path Pi includes at least one o' these nodes, or c \utputs Qcorrectl7R that no such set o' at most k nodes exists. Sour algorithm should use at most a pol7nomial num+er o' steps, to0 gether with at most a pol7nomial num+er o' calls to the algorithm 0 .

11.

As some people remem+er, and man7 have +een told, the idea o' h7per0 text predates the ]orld ]ide ]e+ +7 decades. _ven h7pertext 'iction is a relativel7 old idea@ `ather than +eing constrained +7 the linearit7 o' the printed page, 7ou can plot a stor7 that consists o' a collection o' interlocHed virtual 8places9 ^oined +7 virtual 8passages.9? (o a piece o' h7pertext 'iction is reall7 riding on an underl7ing directed graph6 to +e concrete Qthough narrowing the 'ull range o' what the domain can doR, weXll model this as 'ollows. WetXs view the structure o' a piece o' h7pertext 'iction as a directed graph ' ( , )!. _ach node u $ ( contains some text6 when the reader is currentl7 at u , he or she can choose to 'ollow an7 edge out o' u 6 and i' the reader chooses e u , v!, he or she arrives next at the node v . /here is a start node s $ ( where the reader +egins, and an end node t $ ( 6 when the reader 'irst reaches t , the stor7 ends. /hus an7 path 'rom s to t is a valid plot o' the stor7. Tote that, unliHe oneXs experience using a ]e+ +rowser, there is not necessaril7 a wa7 to go +acH6 once 7ouXve gone 'rom u to v, 7ou might not +e a+le to ever return to u . 1n this wa7, the h7pertext structure de'ines a huge num+er o' di''er0 ent plots on the same underl7ing content6 and the relationships among all these possi+ilities can grow ver7 intricate. >ereXs a t7pe o' pro+lem one encounters when reasoning a+out a structure liHe this. )onsider a piece o' h7pertext 'iction +uilt on a graph ' ( , )! in which there are certain crucial thematic elements @ love, death, war, an intense desire to ma^or in computer science, and so 'orth. _ach thematic element i is rep0 resented +7 a set -i ! ( consisting o' the nodes in ' at which this theme

H"ercises
?

(ee, e.g., http*++www,eastgate,com.

!*7 !*7

!*1 !*1

+hapter ,

-. and +omputational )ntractability

appears. Tow, given a particular set o' thematic elements, we ma7 asH@ 1s there a valid plot o' the stor7 in which each o' these elements is encoun0 teredY Fore concretel7, given a directed graph ' , with start node s and end node t , and thematic elements represented +7 sets -3, -= , . . . , -k , the Plot Fulfillment Problem asHs@ 1s there a path 'rom s to t that contains at least one node 'rom each o' the sets -i Y *rove that *lot Ful'illment is T*0complete. 1&. (ome 'riends o' 7ours maintain a popular news and discussion site on the ]e+, and the tra''ic has reached a level where the7 want to +egin di''erentiating their visitors into pa7ing and nonpa7ing customers. A standard wa7 to do this is to maHe all the content on the site availa+le to customers who pa7 a monthl7 su+scription 'ee6 meanwhile, visitors who donXt su+scri+e can still view a su+set o' the pages Qall the while +eing +om+arded with ads asHing them to +ecome su+scri+ersR. >ere are two simple wa7s to control access 'or nonsu+scri+ers@ Sou could Q1R designate a 'ixed su+set o' pages as viewa+le +7 nonsu+scri+ers, or Q&R allow an7 page in principle to +e viewa+le, +ut speci'7 a maximum num+er o' pages that can +e viewed +7 a nonsu+scri+er in a single session. Q]eXll assume the site is a+le to tracH the path 'ollowed +7 a visitor through the site.R Sour 'riends are experimenting with a wa7 o' restricting access that is di''erent 'rom and more su+tle than either o' these two options. /he7 want nonsu+scri+ers to +e a+le to sample di''erent sections o' the ]e+ site, so the7 designate certain su+sets o' the pages as constituting particular -ones a'or example, there can +e a zone 'or pages on politics, a zone 'or pages on music, and so 'orth. 1tXs possi+le 'or a page to +elong to more than one zone. Tow, as a nonsu+scri+ing user passes through the site, the access polic7 allows him or her to visit one page 'rom each zone, +ut an attempt +7 the user to access a second page 'rom the same zone later in the +rowsing session will +e disallowed. Q1nstead, the user will +e directed to an ad suggesting that he or she +ecome a su+scri+er.R Fore 'ormall7, we can model the site as a directed graph ' (, )!, in which the nodes represent ]e+ pages and the edges represent directed h7perlinHs. /here is a distinguished entr! node s $ ( , and there are -ones 73, . . . , 7k ! ( . A path P taHen +7 a nonsu+scri+er is restricted to include at most one node 'rom each zone 7i . \ne issue with this more complicated access polic7 is that it gets di''icult to answer even +asic Nuestions a+out reacha+ilit7, including@ 1s it possi+le 'or a nonsu+scri+er to visit a given node t Y

H"ercises !** Fore precisel7, we de'ine the Evasive Path Problem as 'ollows@ Viven !** ' , 73, . . . , 7k , s $ ( , and

!*6 !*6

+hapter ,

-. and +omputational )ntractability

a destination node t $ ( , is there an s0t path in ' that includes at most one node 'rom each zone 7i Y *rove that _vasive *ath is T*0 complete. 13. A combinatorial auction is a particular mechanism developed +7 econo0 mists 'or selling a collection o' items to a collection o' potential +u7ers. Q/he Federal )ommunications )ommission has studied this t7pe o' auc0 tion 'or assigning stations on the radio spectrum to +roadcasting com0 panies.R >ereXs a simple t7pe o' com+inatorial auction. /here are n items 'or sale, la+eled &3, . . . , &n . _ach item is indivisi+le and can onl7 +e sold to one person. Tow, m di''erent people place bids @ /he ith +id speci'ies a su+set %i o' the items, and an offering price xi that the +idder is willing to pa7 'or the items in the set %i , as a single unit. Q]eXll represent this +id as the pair %i , xi !.R An auctioneer now looHs at the set o' all m +ids6 she chooses to accept some o' these +ids and to re.ect the others. _ach person whose +id i is accepted gets to taHe all the items in the corresponding set %i . /hus the rule is that no two accepted +ids can speci'7 sets that contain a common item, since this would involve giving the same item to two di''erent people. /he auctioneer collects the sum o' the o''ering prices o' all accepted +ids. QTote that this is a 8one0shot9 auction6 there is no opportunit7 to place 'urther +ids.R /he auctioneerXs goal is to collect as much mone7 as possi+le. /hus, the pro+lem o' /inner %etermination for &ombinatorial 'uc$ tions asHs@ Viven items &3, . . . , &n , +ids %3, x3! , . . . , %m , xm !, and a +ound 1, is there a collection o' +ids that the auctioneer can accept so as to collect an amount o' mone7 that is at least 1Y _xample. (uppose an auctioneer decides to use this method to sell some excess computer eNuipment. /here are 'our items la+eled 8.+,9 8moni- tor,9 8printer9, and 8scanner96 and three people place +ids. Ee'ine ".+ , monitor# , %= scanner# %3 and x3 x= x> 3. ".+ , printer# , %> "monitor , printer ,

/he +ids are %3, x3! , %= , x=! , %> , x>!, and the +ound 1 is eNual to =. /hen the answer to this instance is no@ /he auctioneer can accept at most one o' the +ids Qsince an7 two +ids have a desired item in commonR, and this results in a total monetar7 value o' onl7 3.

*rove that the pro+lem o' ]inner Eetermination in )om+inatorial Auctions is T*0 complete. 14. ]eXve seen the 1nterval (cheduling *ro+lem in )hapters 1 and 4. >ere we consider a computationall7 much harder version o' it that weXll call ultiple 0nterval Scheduling . As +e'ore, 7ou have a processor that is availa+le to run ^o+s over some period o' time Qe.g., D A.F. to < *.FR. *eople su+mit ^o+s to run on the processor6 the processor can onl7 worH on one ^o+ at an7 single point in time. Oo+s in this model, however, are more complicated than weXve seen in the past@ each ^o+ reNuires a set o' intervals o' time during which it needs to use the processor. /hus, 'or example, a single ^o+ could reNuire the processor 'rom 1G A.F. to 11 A.F., and again 'rom & *.F. to 3 *.F.. 1' 7ou accept this ^o+, it ties up 7our processor during those two hours, +ut 7ou could still accept ^o+s that need an7 other time periods Qincluding the hours 'rom 11 A.F. to & A.F.R. Tow 7ouXre given a set o' n ^o+s, each speci'ied +7 a set o' time intervals, and 7ou want to answer the 'ollowing Nuestion@ For a given num+er k, is it possi+le to accept at least k o' the ^o+s so that no two o' the accepted ^o+s have an7 overlap in timeY (how that Fultiple 1nterval (cheduling is T*0complete. 1<. SouXre sitting at 7our desH one da7 when a Fed_x pacHage arrives 'or 7ou. 1nside is a cell phone that +egins to ring, and 7ouXre not entirel7 surprised to discover that itXs 7our 'riend Teo, whom 7ou havenXt heard 'rom in Nuite a while. )onversations with Teo all seem to go the same wa7@ >e starts out with some +ig melodramatic ^usti'ication 'or wh7 heXs calling, +ut in the end it alwa7s comes down to him tr7ing to get 7ou to volunteer 7our time to help with some pro+lem he needs to solve. /his time, 'or reasons he canXt go into Qsomething having to do with protecting an underground cit7 'rom Hiller ro+ot pro+esR, he and a 'ew associates need to monitor radio signals at various points on the electromagnetic spectrum. (peci'icall7, there are n di''erent 'reNuencies that need monitoring, and to do this the7 have availa+le a collection o' sensors . /here are two components to the monitoring pro+lem.
.

A set , o' m geographic locations at which sensors can +e placed6

and
.

A set % o' b interference sources , each o' which +locHs certain 're0 Nuencies at certain locations. (peci'icall7, each inter'erence source i is speci'ied +7 a pair >i , ,i !, where >i is a su+set o' the 'reNuencies and ,i is a su+set o' the locations6 it signi'ies that Qdue to radio inter0

'erenceR a sensor placed at an7 location in the set ,i will not +e a+le to receive signals on an7 'reNuenc7 in the set >i . ]e sa7 that a su+set , ! , o' locations is sufficient i', 'or each o' the n 'reNuencies 6 , there is some location in , where 'reNuenc7 6 is not +locHed +7 an7 inter'erence source. /hus, +7 placing a sensor at each location in a su''icient set, 7ou can success'ull7 monitor each o' the n 'reNuencies. /he7 have k sensors, and hence the7 want to Hnow whether there is a su''icient set o' locations o' size at most k. ]eXll call this an instance o' the Nearb! Electromagnetic 1bservation Problem @ Viven 'reNuencies, locations, inter'erence sources, and a parameter k, is there a su''icient set o' size at most kY _xample. (uppose we have 'our 'reNuencies "f3, f= , f>, f?# and 'our locations " 3, = , >, ?#. /here are three inter'erence sources, with >3, ,3! "f3, f=# , " 3, = , >= , ,=! " f> , f? # , " > , # ! > , , ! " f= , f> # , " ? > > 3#!
>#!

/hen there is a su''icient set o' size &@ ]e can choose locations = and ? Qsince f3 and f= are not +locHed at ?, and f> and f? are not +locHed at =R. *rove that Tear+7 _lectromagnetic \+servation is T*0 complete. 1=. )onsider the pro+lem o' reasoning a+out the identit7 o' a set 'rom the size o' its intersections with other sets. Sou are given a 'inite set . o' size n, and a collection 33, . . . , 3m o' su+sets o' . . Sou are also given num+ers c3, . . . , cm . /he Nuestion is@ Eoes there exist a set X C . so that 'or each i 3, =, . . . , m, the cardinalit7 o' X K 3i is eNual to ci Y ]e will call this an instance o' the 0ntersection 0nference Problem, with input . , "3i #, and "ci #. *rove that 1ntersection 1n'erence is T*0complete. 1?. Sou are given a directed graph ' ( , )! with weights /e on its edges e $ ) . /he weights can +e negative or positive. /he 2ero$/eight$&!cle Problem is to decide i' there is a simple c7cle in ' so that the sum o' the edge weights on this c7cle is exactl7 K. *rove that this pro+lem is T*0complete. 18. SouXve +een asHed to help some organizational theorists anal7ze data on group decision0maHing. 1n particular, the7Xve +een looHing at a dataset that consists o' decisions made +7 a particular

governmental polic7 committee, and the7Xre tr7ing to decide whether itXs possi+le to identi'7 a small set o' in'luential mem+ers o' the committee. >ereXs how the committee worHs. 1t has a set < " m3 , . . . , mn # o' n mem+ers, and over the past 7ear itXs voted on t di''erent issues. \n each issue, each mem+er can vote either 8Ses,9 8To,9 or 8A+stain96 the overall

e''ect is that the committee presents an a''irmative decision on the issue i' the num+er o' 8Ses9 votes is strictl7 greater than the num+er o' 8To9 votes Qthe 8A+stain9 votes donXt count 'or either sideR, and it delivers a negative decision otherwise. Tow we have a +ig ta+le consisting o' the vote cast +7 each committee mem+er on each issue, and weXd liHe to consider the 'ollowing de'inition. ]e sa7 that a su+set o' the mem+ers < ! < is decisive i', had we looHed ^ust at the votes cast +7 the mem+ers in < , the committeeXs decision on ever! issue would have +een the same. Q1n other words, the overall outcome o' the voting among the mem+ers in < is the same on ever7 issue as the overall outcome o' the voting +7 the entire committee.R (uch a su+set can +e viewed as a Hind o' 8inner circle9 that re'lects the +ehavior o' the committee as a whole. >ereXs the Nuestion@ Viven the votes cast +7 each mem+er on each issue, and given a parameter k, we want to Hnow whether there is a deci0 sive su+set consisting o' at most k mem+ers. ]eXll call this an instance o' the %ecisive Subset Problem. _xample. (uppose we have 'our committee mem+ers and three issues. ]eXre looHing 'or a decisive set o' size at most k =, and the voting went as 'ollows.

Issue : )ssue 3 )ssue = )ssue >

m3 Ies *bstain Ies

m= Ies -o *bstain

m> *bstain -o Ies

m? -o *bstain Ies

/hen the answer to this instance is 8Ses,9 since mem+ers m3 and m> constitute a decisive su+set. *rove that Eecisive (u+set is T*0complete. 1D. (uppose 7ouXre acting as a consultant 'or the port authorit7 o' a small *aci'ic `im nation. /he7Xre currentl7 doing a multi0+illion0dollar +usiness per 7ear, and their revenue is constrained almost entirel7 +7 the rate at which the7 can unload ships that arrive in the port. >andling hazardous materials adds additional complexit7 to what is, 'or them, an alread7 complicated tasH. (uppose a convo7 o' ships arrives in the morning and delivers a total o' n cannisters, each containing a di''erent Hind o' hazardous material. (tanding on the docH is a set o' m trucHs, each o' which can hold up to k containers.

>ere are two related pro+lems, which arise 'rom di''erent t7pes o' constraints that might +e placed on the handling o' hazardous materials. For each o' the two pro+lems, give one o' the 'ollowing two answers@
.

A pol7nomial0time algorithm to solve it6 or A proo' that it is T*0complete. For each cannister, there is a speci'ied su+set o' the trucHs in which it ma7 +e sa'el7 carried. 1s there a wa7 to load all n cannisters into the m trucHs so that no trucH is overloaded, and each container goes in a trucH that is allowed to carr7 itY 1n this di''erent version o' the pro+lem, an7 cannister can +e placed in an7 trucH6 however, there are certain pairs o' cannisters that cannot +e placed together in the same trucH. Q/he chemicals the7 contain ma7 react explosivel7 i' +rought into contact.R 1s there a wa7 to load all n cannisters into the m trucHs so that no trucH is overloaded, and no two cannisters are placed in the same trucH when the7 are not supposed to +eY

QaR

Q+R

&G. /here are man7 di''erent wa7s to 'ormalize the intuitive pro+lem o' clustering , where the goal is to divide up a collection o' o+^ects into groups that are 8similar9 to one another. First, a natural wa7 to express the input to a clustering pro+lem is via a set o' o+^ects p3, p= , . . . , pn , with a numerical distance d pi , p6 ! de'ined on each pair. Q]e reNuire onl7 that d pi , pi ! G K6 that d pi , p6 ! @ K 'or distinct pi and p6 6 and that distances are s7mmetric@ d pi , p6 ! G d p6 , pi !.R 1n (ection 4.?, earlier in the +ooH, we considered one reasona+le 'ormulation o' the clustering pro+lem@ Eivide the o+^ects into k sets so as to ma3imi-e the minimum distance +etween an7 pair o' o+^ects in distinct clusters. /his turns out to +e solva+le +7 a nice application o' the Finimum (panning /ree *ro+lem. A di''erent +ut seemingl7 related wa7 to 'ormalize the clustering pro+lem would +e as 'ollows@ Eivide the o+^ects into k sets so as to minimi-e the maximum distance +etween an7 pair o' o+^ects in the same cluster. Tote the change. ]here the 'ormulation in the previous paragraph sought clusters so that no two were 8close together,9 this new 'ormulation seeHs clusters so that none o' them is too 8wide9athat is, no cluster contains two points at a large distance 'rom each other. Viven the similarities, itXs perhaps surprising that this new 'ormula0 tion is computationall7 hard to solve optimall7. /o +e a+le to thinH a+out this in terms o' T*0completeness, letXs write it 'irst as a

7esbno decision pro+lem. Viven n o+^ects p3, p= , . . . , pn with distances on them as a+ove,

and a +ound 1, we de'ine the 4ow$%iameter &lustering Problem as 'ol0 lows@ )an the o+^ects +e partitioned into k sets, so that no two points in the same set are at a distance greater than 1 'rom each otherY *rove that Wow0Eiameter )lustering is T*0 complete.

&1. A'ter a 'ew too man7 da7s immersed in the popular entrepreneurial sel'0 help +ooH ine Your 1wn 5usiness , 7ouXve come to the realization that 7ou need to upgrade 7our o''ice computing s7stem. /his, however, leads to some tricH7 pro+lems. 1n con'iguring 7our new s7stem, there are k components that must +e selected@ the operating s7stem, the text editing so'tware, the e0mail program, and so 'orth6 each is a separate component. For the 6 th compo0 nent o' the s7stem, 7ou have a set 36 o' options6 and a configuration o' the s7stem consists o' a selection o' one element 'rom each o' the sets o' options 33, 3= , . . . , 3k . Tow the trou+le arises +ecause certain pairs o' options 'rom di''erent sets ma7 not +e compati+le. ]e sa7 that option xi $ 3i and option x6 $ 36 'orm an incompatible pair i' a single s7stem cannot contain them +oth. QFor example, Winux Qas an option 'or the operating s7stemR and Ficroso't ]ord Qas an option 'or the text0 editing so'twareR 'orm an incompati+le pair.R ]e sa7 that a con'iguration o' the s7stem is full! compatible i' it consists o' elements x3 $ 33, x= $ 3= , . . . xk $ 3k such that none o' the pairs xi , x6 ! is an incompati+le pair. ]e can now de'ine the Full! &ompatible &onfiguration 6F&&7 Problem . An instance o' F)) consists o' dis^oint sets o' options 33, 3= , . . . , 3k , and a set P o' incompatible pairs x , y!, where x and y are elements o' di''erent sets o' options. /he pro+lem is to decide whether there exists a 'ull7 compati+le con'iguration@ a selection o' an element 'rom each option set so that no pair o' selected elements +elongs to the set P . _xample. (uppose k >, and the sets 33, 3= , 3> denote options 'or the operating s7stem, the text0editing so'tware, and the e0mail program, respectivel7. ]e have 33 3= 3> "Cinu" , Windows -/# , "emacs, Word# , "%utlook , Hudora , rmail# ,

with the set o' incompati+le pairs eNual to

" Cinu" , Word! , Cinu" , %utlook! , Word , rmail!#.

/hen the answer to the decision pro+lem in this instance o' F)) is 7esa'or example, the choices Cinu" $ 33, emacs $ 3= , rmail $ 3> is a 'ull7 compati+le con'iguration according to the de'initions a+ove. *rove that complete. Full7 )ompati+le )on'iguration is T*0

&&. (uppose that someone gives 7ou a +lacH0+ox algorithm * that taHes an undirected graph ' ( , )!, and a num+er k, and +ehaves as 'ollows. 1' ' is not connected, it simpl7 returns 8' is not connected.9
. .

1' ' is connected and has an independent set o' size at least k, it returns 87es.9 1' ' is connected and does not have an independent set o' size at least k, it returns 8no.9

(uppose that the algorithm * runs in time pol7nomial in the size o' ' and k. (how how, using calls to * , 7ou could then solve the 1ndependent (et *ro+lem in pol7nomial time@ Viven an ar+itrar7 undirected graph ' , and a num+er k, does ' contain an independent set o' size at least kY &3. Viven a set o' 'inite +inar7 strings % "s3, . . . , sk #, we sa7 that a string u is a concatenation over % i' it is eNual to si3si= . . . sit 'or some indices i3, . . . , it $ "3, . . . , k#. A 'riend o' 7ours is considering the 'ollowing pro+lem@ Viven two sets o' 'inite +inar7 strings, 3 "a3, . . . , am # and 1 "b3, . . . , bn #, does there exist an7 string u so that u is +oth a concatenation over 3 and a concatenation over 1Y Sour 'riend announces, 8At least the pro+lem is in -., since 1 would ^ust have to exhi+it such a string u in order to prove the answer is 7es.9 Sou point out Qpolitel7, o' courseR that this is a completel7 inadeNuate explanation6 how do we Hnow that the shortest such string u doesnXt have length exponential in the size o' the input, in which case it would not +e a pol7nomial0size certi'icateY >owever, it turns out that this claim can +e turned into a proo' o' mem+ership in -.. (peci'icall7, prove the 'ollowing statement. &f there is a string u that is a concatenation over both 3 and 1# then there is such a string /hose length is bounded by a polynomial in the sum of the lengths of the strings in 3 B 1. &4. Wet ' ( , )! +e a +ipartite graph6 suppose its nodes are partitioned into sets X and Y so that each edge has one end in X and the other in

Y . ]e de'ine an a , b!$skeleton o' ' to +e a set o' edges ) ! ) so that at most

a nodes in X are incident to an edge in ) , and at least b nodes in Y are incident to an edge in ) . (how that, given a +ipartite graph ' and num+ers a and b, it is T*0 complete to decide whether ' has an a , b!0sHeleton. &<. For 'unctions g3, . . . , g , we de'ine the 'unction ma" g3, . . . , g ! via Uma" g3, . . . , g !V x! ma" g3 x! , . . . , g x!!.

)onsider the 'ollowing pro+lem. Sou are given n piecewise linear, continuous 'unctions f3, . . . , fn de'ined over the interval UK, t V 'or some integer t . Sou are also given an integer 1. Sou want to decide@ Eo there exist k o' the 'unctions fi3 , . . . , fik so that
t K

Uma" fi3 , . . . , fik !V x! dx d 19

*rove that this pro+lem is T*0complete. &=. Sou and a 'riend have +een treHHing through various 'ar0o'' parts o' the world and have accumulated a +ig pile o' souvenirs. At the time 7ou werenXt reall7 thinHing a+out which o' these 7ou were planning to Heep and which 7our 'riend was going to Heep, +ut now the time has come to divide ever7thing up. >ereXs a wa7 7ou could go a+out doing this. (uppose there are n o+^ects, la+eled 3, =, . . . , n, and o+^ect i has an agreed0upon value xi . Q]e could thinH o' this, 'or example, as a monetar7 resale value6 the case in which 7ou and 7our 'riend donXt agree on the value is something we wonXt pursue here.R \ne reasona+le wa7 to divide things would +e to looH 'or a partition o' the o+^ects into two sets, so that the total value o' the o+^ects in each set is the same. /his suggests solving the 'ollowing Number Partitioning Problem. Sou are given positive integers x3, . . . , xn 6 7ou want to decide whether the num+ers can +e partitioned into two sets %3 and %= with the same sum@ xi
xi $%3 x6 $%=

x6 .

(how that Tum+er *artitioning is T*0complete. &?. )onsider the 'ollowing pro+lem. Sou are given positive integers x3, . . . , xn , and num+ers k and 1. Sou want to Hnow whether it is possi+le to partition

the num+ers "xi # into k sets %3, . . . , %k so that the sNuared sums o' the sets add up to at most 1@ =
k

i 3

x6
x6 $%i

1.

(how that this pro+lem is T*0complete. &8. /he 'ollowing is a version o' the 1ndependent (et *ro+lem. Sou are given a graph ' ( , )! and an integer k. For this pro+lem, we will call a set & C ( strongl! independent i', 'or an7 two nodes v , u $ & , the edge v , u! does not +elong to ) , and there is also no path o' two edges 'rom u to v, that is, there is no node / such that +oth u , /! $ ) and / , v! $ ) . /he (trongl7 1ndependent (et *ro+lem is to decide whether ' has a strongl7 independent set o' size at least k. *rove that the (trongl7 1ndependent (et *ro+lem is T*0complete. &D. SouXre con'iguring a large networH o' worHstations, which weXll model as an undirected graph ' 6 the nodes o' ' represent individual worHstations and the edges represent direct communication linHs. /he worHstations all need access to a common core database, which contains data necessar7 'or +asic operating s7stem 'unctions. Sou could replicate this data+ase on each worHstation6 this would maHe looHups ver7 'ast 'rom an7 worHstation, +ut 7ouXd have to manage a huge num+er o' copies. Alternatel7, 7ou could Heep a single cop7 o' the data+ase on one worHstation and have the remaining worHstations issue reNuests 'or data over the networH ' 6 +ut this could result in large dela7s 'or a worHstation thatXs man7 hops awa7 'rom the site o' the data+ase. (o 7ou decide to looH 'or the 'ollowing compromise@ Sou want to maintain a small num+er o' copies, +ut place them so that an7 worHsta0 tion either has a cop7 o' the data+ase or is connected +7 a direct linH to a worHstation that has a cop7 o' the data+ase. 1n graph terminolog7, such a set o' locations is called a dominating set . /hus we phrase the %ominating Set Problem as 'ollows. Viven the networH ' , and a num+er k, is there a wa7 to place k copies o' the data+ase at k di''erent nodes so that ever7 node either has a cop7 o' the data+ase or is connected +7 a direct linH to a node that has a cop7 o' the data+aseY (how that Eominating (et is T*0complete. 3G. \ne thing thatXs not alwa7s apparent when thinHing a+out traditional 8continuous math9 pro+lems is the wa7 discrete, com+inatorial issues

+hapter ,

-. and +omputational )ntractability

o' the Hind weXre stud7ing here can creep into what looH liHe standard calculus Nuestions. )onsider, 'or example, the traditional pro+lem o' minimizing a one0 varia+le 'unction liHe f x! > ; x % >x= over an interval liHe x $ UK, 3V. /he derivative has a zero at x 3DA, +ut this in 'act is a maximum o' the 'unction, not a minimum6 to get the minimum, one has to heed the standard warning to checH the values on the +oundar7 o' the in0 terval as well. Q/he minimum is in 'act achieved on the +oundar7, at x 3.R )hecHing the +oundar7 isnXt such a pro+lem when 7ou have a 'unction in one varia+le6 +ut suppose weXre now dealing with the pro+lem o' minimizing a 'unction in n varia+les x3, x= , . . . , xn over the unit cu+e, where each o' x3, x= , . . . , xn $ UK, 3V. /he minimum ma7 +e achieved on the interior o' the cu+e, +ut it ma7 +e achieved on the +oundar76 and this latter prospect is rather daunting, since the +oundar7 consists o' =n 8corners9 Qwhere each xi is eNual to either K or 3R as well as various pieces o' other dimensions. )alculus +ooHs tend to get suspiciousl7 vague around here, when tr7ing to descri+e how to handle multivaria+le minimization pro+lems in the 'ace o' this complexit7. 1t turns out thereXs a reason 'or this@ Finimizing an n0varia+le 'unc0 tion over the unit cu+e in n dimensions is as hard as an T*0 complete pro+lem. /o maHe this concrete, letXs consider the special case o' pol70 nomials with integer coe''icients over n varia+les x3, x= , . . . , xn . /o review some terminolog7, we sa7 a monomial is a product o' a real0num+er co0 e''icient c and each varia+le xi raised to some nonnegative integer power a3 a= n = ? ai 6 we can write this as cx x . . .ax n . QFor example, =x3x=x> is a 3 = monomial.R A pol!nomial is then a sum o' a 'inite set o' monomials. QFor example, = ? = = =x3 x =x > ; x3x> % Ax = x > is a pol7nomial.R ]e de'ine the ultivariable Pol!nomial inimi-ation Problem as 'ol0 lows@ Viven a pol7nomial in n varia+les with integer coe''icients, and given an integer +ound 1, is there a choice o' real num+ers x3, x= , . . . , xn $ UK, 3V that causes the pol7nomial to achieve a value that is 1Y )hoose a pro+lem Y 'rom this chapter that is Hnown to +e T*0 complete and show that Y P ;ultivariable .olynomial ;inimi ation. 31. Viven an undirected graph ' ( , )!, a feedback set is a set X ! (

H"ercises

with the propert7 that ' % X has no c7cles. /he (ndirected Feedback Set Problem asHs@ Viven ' and k, does ' contain a 'eed+acH set o' size at most kY *rove that Undirected Feed+acH (et is T*0complete.

1"
3&.

+hapter ,

-. and +omputational )ntractability

/he mapping o' genomes involves a large arra7 o' di''icult computational pro+lems. At the most +asic level, each o' an organismXs chromosomes can +e viewed as an extremel7 long string Qgenerall7 containing millions o' s7m+olsR over the 'our0letter alpha+et L3, " , ' , - M. \ne 'amil7 o' ap0 proaches to genome mapping is to generate a large num+er o' short, overlapping snippets 'rom a chromosome, and then to in'er the 'ull long string representing the chromosome 'rom this set o' overlapping su+0 strings. ]hile we wonXt go into these string assem+l7 pro+lems in 'ull detail, hereXs a simpli'ied pro+lem that suggests some o' the computational di'0 'icult7 one encounters in this area. (uppose we have a set % G Ls3, s= , . . . , sn M o' short ETA strings over a 00letter alpha+et6 and each string si has length = , 'or some num+er W 3. ]e also have a li+rar7 o' additional strings - G Lt3, t= , . . . , tm M over the same alpha+et6 each o' these also has length = . 1n tr7ing to assess whether the string sb might come directl7 a'ter the string sa in the chromosome, we will looH to see whether the li+rar7 - contains a string tk so that the 'irst s7m+ols in tk are eNual to the last s7m+ols in sa , and the last s7m+ols in tk are eNual to the 'irst s7m+ols in sb. 1' this is possi+le, we will sa7 that tk corroborates the pair sa , sb!. Q1n other words, tk could +e a snippet o' ETA that straddled the region in which sb directl7 'ollowed sa .R Tow weXd liHe to concatenate all the strings in % in some order, one a'ter the other with no overlaps, so that each consecutive pair is corro+orated +7 some string in the li+rar7 - . /hat is, weXd liHe to order the strings in % as si3 , si= , . . . , sin , where i3, i= , . . . , in is a permutation o' L3, =, . . . , nM, so that 'or each 6 G 3, =, . . . , n P 3, there is a string tk that corro+orates the pair si6 , O si6 3!. Q/he same string tk can +e used 'or more than one consecutive pair in the concatenation.R 1' this is possi+le, we will sa7 that the set % has a perfect assembl! . Viven sets % and - , the Perfect 'ssembl! Problem asHs@ Eoes % have a per'ect assem+l7 with respect to - Y *rove that *er'ect Assem+l7 is T*0 complete. _xample. (uppose the alpha+et is L3, " , ' , - M, the set % G L3' , -" , -3M, and the set - G L3" , "3, '" , '- M Qso each string has length = G =R. /hen the answer to this instance o' *er'ect Assem+l7 is 7es@ ]e can concatenate the three strings in % in the order -"3'-3 Qso si3 G s=, si= G s3, and si> G s>R. 1n this order, the pair si3 , si=! is corro+orated +7

H"ercises the string "3 in the li+rar7 - , and the pair si= , si>! is corro+orated +7 the string '- in the li+rar7 - . 33. 1n a +arter econom7, people trade goods and services directl7, without mone7 as an intermediate step in the process. /rades happen when each

11

1!

+hapter ,

-. and +omputational )ntractability

part7 views the set o' goods the7Xre getting as more valua+le than the set o' goods the7Xre giving in return. >istoricall7, societies tend to move 'rom +arter0+ased to mone70+ased economies6 thus various online s7stems that have +een experimenting with +arter can +e viewed as intentional attempts to regress to this earlier 'orm o' economic interaction. 1n doing this, the7Xve rediscovered some o' the inherent di''iculties with +arter relative to mone70+ased s7stems. \ne such di''icult7 is the complexit7 o' identi'7ing opportunities 'or trading, even when these opportunities exist. /o model this complexit7, we need a notion that each person assigns a value to each o+^ect in the world, indicating how much this o+^ect would +e worth to them. /hus we assume there is a set o' n people p3, . . . , pn , and a set o' m distinct o+^ects a3, . . . , am . _ach o+^ect is owned +7 one o' the people. Tow each person pi has a valuation function vi , de'ined so that vi a6 ! is a nonnegative num+er that speci'ies how much o+^ect a6 is worth to pi athe larger the num+er, the more valua+le the o+^ect is to the person. Tote that ever7one assigns a valuation to each o+^ect, including the ones the7 donXt currentl7 possess, and di''erent people can assign ver7 di''erent valuations to the same o+^ect. A two0person trade is possi+le in a s7stem liHe this when there are people pi and p6 , and su+sets o' o+^ects 3i and 36 possessed +7 pi and p6 , respectivel7, so that each person would pre'er the o+^ects in the su+set the7 donXt currentl7 have. Fore precisel7,
.

pi Xs total valuation 'or the o+^ects in 36 exceeds his or her total valuation 'or the o+^ects in 3i , and p6 Xs total valuation 'or the o+^ects in 3i exceeds his or her total valuation 'or the o+^ects in 36 .

QTote that 3i doesnXt have to +e all the o+^ects possessed +7 pi Qand liHewise 'or 36 R6 3i and 36 can +e ar+itrar7 su+sets o' their possessions that meet these criteria.R (uppose 7ou are given an instance o' a +arter econom7, speci'ied +7 the a+ove data on peopleXs valuations 'or o+^ects. Q/o prevent pro+0 lems with representing real num+ers, weXll assume that each personXs valuation 'or each o+^ect is a natural num+er.R *rove that the pro+lem o' determining whether a two0person trade is possi+le is T*0complete. 34. 1n the 1D?Gs, researchers including FarH Vranovetter and /homas (chelling in the mathematical social sciences +egan tr7ing to develop models o' certain Hinds o' collective human +ehaviors@ ]h7 do particu0 lar 'ads catch on while others die outY ]h7 do particular technological innovations achieve widespread adoption, while others remain 'ocused

H"ercises

1#

on a small group o' usersY ]hat are the d7namics +7 which rioting and looting +ehavior sometimes Q+ut onl7 rarel7R emerges 'rom a crowd o' angr7 peopleY /he7 proposed that these are all examples o' cascade processes , in which an individualXs +ehavior is highl7 in'luenced +7 the +ehaviors o' his or her 'riends, and so i' a 'ew individuals instigate the process, it can spread to more and more people and eventuall7 have a ver7 wide impact. ]e can thinH o' this process as +eing liHe the spread o' an illness, or a rumor, ^umping 'rom person to person. /he most +asic version o' their models is the 'ollowing. /here is some underl7ing behavior Qe.g., pla7ing ice hocHe7, owning a cell phone, taHing part in a riotR, and at an7 point in time each person is either an adopter o' the +ehavior or a nonadopter . ]e represent the population +7 a directed graph ' ( , )! in which the nodes correspond to people and there is an edge v , /! i' person v has in'luence over the +ehavior o' person /@ 1' person v adopts the +ehavior, then this helps induce person / to adopt it as well. _ach person / also has a given threshold E /! $ UK, 3V, and this has the 'ollowing meaning@ At an7 time when at least a E /! 'raction o' the nodes with edges to / are adopters o' the +ehavior, the node / will +ecome an adopter as well. Tote that nodes with lower thresholds are more easil7 convinced to adopt the +ehavior, while nodes with higher thresholds are more conservative. A node / with threshold E /! K will adopt the +ehavior immediatel7, with no inducement 'rom 'riends. Finall7, we need a conven0 tion a+out nodes with no incoming edges@ ]e will sa7 that the7 +ecome adopters i' E /! K, and cannot +ecome adopters i' the7 have an7 larger threshold. Viven an instance o' this model, we can simulate the spread o' the +ehavior as 'ollows.

)nitially, set all nodes / with E /! K to be adopters 6*ll other nodes start out as nonadopters7 Until there is no change in the set of adopters( 1or each nonadopter / simultaneously( )f at least a E /! fraction of nodes with edges to / are adopters then / becomes an adopter Hndif Hndfor Hnd %utput the final set of adopters

11

+hapter ,

-. and +omputational )ntractability

Tote that this process terminates, since there are onl7 n individuals total, and at least one new person +ecomes an adopter in each iteration. Tow, in the last 'ew 7ears, researchers in marHeting and data min0 ing have looHed at how a model liHe this could +e used to investigate 8word0o'0mouth9 e''ects in the success o' new products Qthe so0called viral marketing phenomenonR. /he idea here is that the +ehavior weXre concerned with is the use o' a new product6 we ma7 +e a+le to convince a 'ew He7 people in the population to tr7 out this product, and hope to trigger as large a cascade as possi+le. )oncretel7, suppose we choose a set o' nodes % ! ( and we reset the threshold o' each node in % to K. QP7 convincing them to tr7 the product, weXve ensured that the7Xre adopters.R ]e then run the process descri+ed a+ove, and see how large the 'inal set o' adopters is. WetXs denote the size o' this 'inal set o' adopters +7 f %! Qnote that we write it as a 'unction o' %, since it naturall7 depends on our choice o' %R. ]e could thinH o' f %! as the influence o' the set %, since it captures how widel7 the +ehavior spreads when 8seeded9 at %. /he goal, i' weXre marHeting a product, is to 'ind a small set % whose in'luence f %! is as large as possi+le. ]e thus de'ine the 0nfluence a3imi-ation Problem as 'ollows@ Viven a directed graph ' ( , )!, with a threshold value at each node, and parameters k and b, is there a set % o' at most k nodes 'or which f %! d bY *rove that 1n'luence Faximization is T*0complete. _xample. (uppose our graph ' ( , )! has 'ive nodes "a , b, c , d , e #, 'our edges a , b! , b, c! , e , d! , d , c!, and all node thresholds eNual to =D>. /hen the answer to the 1n'luence Faximization instance de'ined +7 ' , with k = and b @, is 7es@ ]e can choose % "a , e #, and this will cause the other three nodes to +ecome adopters as well. Q/his is the onl7 choice o' % that will worH here. For example, i' we choose % "a , d#, then b and c will +ecome adopters, +ut e wonXt6 i' we choose % "a , b#, then none o' c , d, or e will +ecome adopters.R 3<. /hree o' 7our 'riends worH 'or a large computer0game compan7, and the7Xve +een worHing hard 'or several months now to get their proposal 'or a new game, %roid Trader8 , approved +7 higher management. 1n the process, the7Xve had to endure all sorts o' discouraging comments, ranging 'rom 8SouXre reall7 going to have to worH with FarHeting on the name9 to 8]h7 donXt 7ou emphasize the parts where people get to HicH each other in the headY9 At this point, though, itXs all +ut certain that the game is reall7 heading into production, and 7our 'riends come to 7ou with one

H"ercises 'inal

1*

16

+hapter ,

-. and +omputational )ntractability

issue thatXs +een worr7ing them@ ]hat i' the overall premise o' the game is too simple, so that pla7ers get reall7 good at it and +ecome +ored too NuicHl7Y 1t taHes 7ou a while, listening to their detailed description o' the game, to 'igure out whatXs going on6 +ut once 7ou strip awa7 the space +attles, HicH0+oxing interludes, and (tars0]ars0inspired pseudo0m7sticism, the +asic idea is as 'ollows. A pla7er in the game controls a spaceship and is tr7ing to maHe mone7 +u7ing and selling droids on di''erent planets. /here are n di''erent t7pes o' droids and k di''erent planets. _ach planet p has the 'ollowing properties@ there are s 6 , p! W K droids o' t7pe 6 availa+le 'or sale, at a 'ixed price o' x 6 , p! W K each, 'or 6 G 3, =, . . . , n6 and there is a demand 'or d 6 , p! W K droids o' t7pe 6 , at a 'ixed price o' y 6 , p! W K each. Q]e will assume that a planet does not simultaneousl7 have +oth a positive suppl7 and a positive demand 'or a single t7pe o' droid6 so 'or each 6 , at least one o' s 6 , p! or d 6 , p! is eNual to K.R /he pla7er +egins on planet s with * units o' mone7 and must end at planet t 6 there is a directed ac7clic graph ' on the set o' planets, such that s0t paths in ' correspond to valid routes +7 the pla7er. Q' is chosen to +e ac7clic to prevent ar+itraril7 long games.R For a given s0t path P in ' , the pla7er can engage in transactions as 'ollows. ]henever the pla7er arrives at a planet p on the path P , she can +u7 up to s 6 , p! droids o' t7pe 6 'or x 6 , p! units o' mone7 each Qprovided she has su''icient mone7 on handR andbor sell up to d 6 , p! droids o' t7pe 6 'or y 6 , p! units o' mone7 each Q'or 6 G 3, =, . . . , nR. /he pla7erXs final score is the total amount o' mone7 she has on hand when she arrives at planet t . Q/here are also +onus points +ased on space +attles and HicH0+oxing, which weXll ignore 'or the purposes o' 'ormulating this Nuestion.R (o +asicall7, the underl7ing pro+lem is to achieve a high score. 1n other words, given an instance o' this game, with a directed ac7clic graph ' on a set o' planets, all the other parameters descri+ed a+ove, and also a target +ound 1, is there a path P in ' and a seNuence o' transactions on P so that the pla7er ends with a 'inal score that is at least 1Y ]eXll call this an instance o' the High$ Score$on$%roid$Trader8 Problem , or >(oE/e 'or short. *rove that >(oE/e is T*0complete, there+7 guaranteeing Qassuming P G NP R that there isnXt a simple strateg7 'or racHing up high scores on 7our 'riendsX game. 3=. (ometimes 7ou can Hnow people 'or 7ears and never reall7 understand them. /aHe 7our 'riends `a^ and Alanis, 'or example. Teither o' them is a morning person, +ut now the7Xre getting up at = AF ever7 da7 to visit

H"ercises

17

local 'armersX marHets, gathering 'resh 'ruits and vegeta+les 'or the new health0'ood restaurant the7Xve opened, )hez Alanisse. 1n the course o' tr7ing to save mone7 on ingredients, the7Xve come across the 'ollowing thorn7 pro+lem. /here is a large set o' n possi+le raw ingredients the7 could +u7, &3, &= , . . . , &n Qe.g., +undles o' dandelion greens, ^ugs o' rice vinegar, and so 'orthR. 1ngredient &6 must +e purchased in units o' size s 6! grams Qan7 purchase must +e 'or a whole num+er o' unitsR, and it costs c 6! dollars per unit. Also, it remains sa'e to use 'or t 6! da7s 'rom the date o' purchase. Tow, over the next k da7s, the7 want to maHe a set o' k di''erent dail7 specials, one each da7. Q/he order in which the7 schedule the specials is up to them.R /he ith dail7 special uses a su+set %i ! "&3, &= , . . . , &n # o' the raw ingredients. (peci'icall7, it reNuires a i , 6! grams o' ingredient &6 . And thereXs a 'inal constraint@ /he restaurantXs ra+idl7 lo7al customer +ase onl7 remains ra+idl7 lo7al i' the7Xre +eing served the 'reshest meals availa+le6 so 'or each dail7 special, the ingredients %i are partitioned into two su+sets@ those that must +e purchased on the ver7 da7 when the dail7 special is +eing o''ered, and those that can +e used an7 da7 while the7Xre still sa'e. QFor example, the mesclun0+asil salad special needs to +e made with +asil that has +een purchased that da76 +ut the arugula0+asil pesto with )ornell dair7 goat cheese special can use +asil that is several da7s old, as long as it is still sa'e.R /his is where the opportunit7 to save mone7 on ingredients comes up. \'ten, when the7 +u7 a unit o' a certain ingredient &6 , the7 donXt need the whole thing 'or the special the7Xre maHing that da7. /hus, i' the7 can 'ollow up NuicHl7 with another special that uses &6 +ut doesnXt reNuire it to +e 'resh that da7, then the7 can save mone7 +7 not having to purchase &6 again. \' course, scheduling the +asil recipes close together ma7 maHe it harder to schedule the goat cheese recipes close together, and so 'ortha this is where the complexit7 comes in. (o we de'ine the %ail! Special Scheduling Problem as 'ollows@ Viven data on ingredients and recipes as a+ove, and a +udget x, is there a wa7 to schedule the k dail7 specials so that the total mone7 spent on ingredients over the course o' all k da7s is at most xY *rove that %ail! Special Scheduling is T*0complete.

3?. /here are those who insist that the initial worHing title 'or _pisode ff[11 o' the (tar ]ars series was 8. -. 9a+ut this is surel7 apocr7phal. 1n an7 case, i' 7ouXre so inclined, itXs eas7 to 'ind T*0 complete pro+lems lurHing ^ust +elow the sur'ace o' the original Star

18

+hapter ,

-. and +omputational )ntractability

/ars movies.

H"ercises

19

)onsider the pro+lem 'aced +7 WuHe, Weia, and 'riends as the7 tried to maHe their wa7 'rom the Eeath (tar +acH to the hidden `e+el +ase. ]e can view the galax7 as an undirected graph ' ( , )!, where each node is a star s7stem and an edge u , v! indicates that one can travel directl7 'rom u to v. /he Eeath (tar is represented +7 a node s, the hidden `e+el +ase +7 a node t . )ertain edges in this graph represent longer distances than others6 thus each edge e has an integer length e d K. Also, certain edges represent routes that are more heavil7 patrolled +7 evil 1mperial spacecra't6 so each edge e also has an integer risk re d K, indicating the expected amount o' damage incurred 'rom special0e''ects0intensive space +attles i' one traverses this edge. 1t would +e sa'est to travel through the outer rim o' the galax7, 'rom one Nuiet upstate star s7stem to another6 +ut then oneXs ship would run out o' 'uel long +e'ore getting to its destination. Alternatel7, it would +e NuicHest to plunge through the cosmopolitan core o' the galax76 +ut then there would +e 'ar too man7 1mperial spacecra't to deal with. 1n general, 'or an7 path P 'rom s to t , we can de'ine its total length to +e the sum o' the lengths o' all its edges6 and we can de'ine its total risk to +e the sum o' the risHs o' all its edges. (o WuHe, Weia, and compan7 are looHing at a complex t7pe o' shortest0 path pro+lem in this graph@ the7 need to get 'rom s to t along a path whose total length and total risH are both reasona+l7 small. 1n concrete terms, we can phrase the 9alactic Shortest$Path Problem as 'ollows@ Viven a setup as a+ove, and integer +ounds , and B, is there a path 'rom s to t whose total length is at most ,, and whose total risH is at most BY *rove that Valactic (hortest *ath is T*0complete. 38. )onsider the 'ollowing version o' the (teiner /ree *ro+lem, which weXll re'er to as 9raphical Steiner Tree. Sou are given an undirected graph ' ( , )!, a set X ! ( o' vertices, and a num+er k. Sou want to decide whether there is a set > ! ) o' at most k edges so that in the graph ( , > !, X +elongs to a single connected component. (how that Vraphical (teiner /ree is T*0complete. 3D. /he %irected %is.oint Paths Problem is de'ined as 'ollows. ]e are given a directed graph ' and k pairs o' nodes s3, t3! , s= , t=! , . . . , sk , tk !. /he pro+lem is to decide whether there exist node0dis^oint paths P3, P= , . . . , Pk so that Pi goes 'rom si to ti . (how that Eirected Eis^oint *aths is T*0complete. 4G. )onsider the 'ollowing pro+lem that arises in the design o'

!"

+hapter , -. and +omputational )ntractability +roadcasting schemes 'or networHs. ]e are given a directed graph ' ( , )!, with a

H"ercises

!1

designated node r $ ( and a designated set o' 8target nodes9 - ! ( % "r #. _ach node v has a switching time sv , which is a positive integer. At time K, the node r generates a message that it would liHe ever7 node in - to receive. /o accomplish this, we want to 'ind a scheme where+7 r tells some o' its neigh+ors Qin seNuenceR, who in turn tell some o' their neigh+ors, and so on, until ever7 node in - has received the message. Fore 'ormall7, a broadcast scheme is de'ined as 'ollows. Tode r ma7 send a cop7 o' the message to one o' its neigh+ors at time K6 this neigh+or will receive the message at time 3. 1n general, at time t d K, an7 node v that has alread7 received the message ma7 send a cop7 o' the message to one o' its neigh+ors, provided it has not sent a cop7 o' the message in an7 o' the time steps t % sv ; 3, t % sv ; =, . . . , t % 3. Q/his re'lects the role o' the switching time 6 v needs a pause o' sv % 3 steps +etween successive sendings o' the message. Tote that i' sv 3, then no restriction is imposed +7 this.R /he completion time o' the +roadcast scheme is the minimum time t +7 which all nodes in - have received the message. /he 5roadcast Time Problem is the 'ollowing@ Viven the input descri+ed a+ove, and a +ound b, is there a +roadcast scheme with completion time at most bY *rove that Proadcast /ime is T*0complete. _xample. (uppose we have a directed graph ' ( , )!, with ( "r , a , b , c #6 edges r , a!, a , b!, r , c!6 the set "b, c #6 and switching time sv = 'or each v $ ( . /hen a +roadcast scheme with minimum completion time would +e as 'ollows@ r sends the message to a at time K6 a sends the message to b at time 36 r sends the message to c at time =6 and the scheme completes at time > when c receives the message. QTote that a can send the message as soon as it receives it at time 3, since this is its 'irst sending o' the message6 +ut r cannot send the message at time 3 since sr = and it sent the message at time K.R 41. Viven a directed graph ' , a c!cle cover is a set o' node0dis^oint c7cles so that each node o' ' +elongs to a c7cle. /he &!cle &over Problem asHs whether a given directed graph has a c7cle cover. QaR (how that the )7cle )over *ro+lem can +e solved in pol7nomial time. QHint* Use Pipartite Fatching.R

Q+R (uppose we reNuire each c7cle to have at most three edges. (how that determining whether a graph ' has such a c7cle cover is T*0complete.

!!

+hapter , 4&.

-. and +omputational )ntractability

(uppose 7ouXre consulting 'or a compan7 in northern Tew Oerse7 that designs communication networHs, and the7 come to 7ou with the 'ollow0

-otes and 1urther 4eading

17

ing pro+lem. /he7Xre stud7ing a speci'ic n0node communication networH, modeled as a directed graph ' ( , )!. For reasons o' 'ault tolerance, the7 want to divide up ' into as man7 virtual 8domains9 as possi+le@ A domain in ' is a set X o' nodes, o' size at least =, so that 'or each pair o' nodes u , v $ X there are directed paths 'rom u to v and v to u that are contained entirel7 in X . (how that the 'ollowing %omain %ecomposition Problem is T*0 com0 plete. Viven a directed graph ' ( , )! and a num+er k, can ( +e parti$ tioned into at least k sets, each o' which is a domainY

-otes and 1urther 4eading


)n the notes to +hapter =, we described some of the early work on formali ing computational efciency using polynomial time5 -.-completeness evolved out of this work and grew into its central role in computer science following the papers of +ook 63NB37, Cevin 63NB>7, and Sarp 63NB=7. Hdmonds 63NA@7 is credited with drawing particular attention to the class of problems in -. K co--.!those with &good characteri ations.' 8is paper also contains the e"plicit conjecture that the /raveling 0alesman .roblem cannot be solved in polynomial time, thereby preguring the P NP $uestion. 0ipser 63NN=7 is a useful guide to all of this historical conte"t. /he book by Darey and Johnson 63NBN7 provides e"tensive material on -.completeness and concludes with a very useful catalog of known -.-complete problems. While this catalog, necessarily, only covers what was known at the time of the books publication, it is still a very useful reference when one encounters a new problem that looks like it might be -.-complete. )n the meantime, the space of known -.-complete problems has continued to e"pand dramatically5 as +hristos .apadimitriou said in a lecture, &4oughly A,KKK papers every year contain an -.-completeness result. /hat means another -.-complete problem has been discovered since lunch.' 68is lecture was at =(KK in the afternoon.7 %ne can interpret -.-completeness as saying that each individual -.complete problem contains the entire comple"ity of -. hidden inside it. * concrete reFection of this is the fact that several of the -.-complete problems we discuss here are the subject of entire books( the /raveling 0alesman is the subject of Cawler et al. 63N,@75 Draph +oloring is the subject of Jensen and /oft 63NN@75 and the Snapsack .roblem is the subject of ;artello and /oth 63NNK7. -.-completeness results for scheduling problems are discussed in the survey by Cawler et al. 63NN>7.

18

+hapter ,

-. and +omputational )ntractability

Notes on the Exercises * number of the e"ercises illustrate further problems that emerged as paradigmatic e"amples early in the development of -.completeness5 these include H"ercises @, =A, =N, >3, >,, >N, ?K, and ?3. H"ercise >> is based on discussions with 2aniel Dolovin, and H"ercise >? is based on our work with 2avid Sempe. H"ercise >B is an e"ample of the class of 1icriteria %hortest-Path problems5 its motivating application here was suggested by ;averick Woo.

You might also like