Problem 1. (30%) Calculaton of tme complexty (3%) Gven n ctes, usng exhaust search to see every result takes O(n!). Calculaton of tme needed to solve the problem (2%) 40 ctes:40! dfferent tours 40 add operatons per each tour computng power: 0.5 trllon add operatons per second: 40! 40/(0.5 10 12 ) seconds = 2069800312653215967391200582435.6 years 1
Problem 2. Brds n a graph (20%) 1. (5%) The correspondng decson problem can be defned as follows: Gven an undrected graph G = (V, E) wth capacty c, V, decde whether k brds can lve n the gven graph wthout fghtng. Because the maxmum number of brds must be n the [max c, c ], we can solve the orgnal optmzaton problem by bnary search on k. That s, fnd the maxmum k such that the decson problem returns true. The bnary search requres solvng the decson problem log c tmes, whch s lnear to the nput sze. If the decson problem belongs to P, there exsts an algorthm solvng t n polynomal tme. By the bnary search on k, we also can solve the orgnal optmzaton problem n polynomal tme. 2. (5%) Gven any brd allocaton as the certfcate, we can check that no two adjacent vertces are occuped by brds n O( V 2 ) and that the number of brds >= k n O( V ). Obvously, the above verfcaton algorthm runs n polynomal tme. For a problem nstance of whch answer s no, t s clear that no such certfcate exsts. Therefore, the decson problem s n NP. 3. (7%) The followng s a reducton from 3-CNF-SAT to the decson problem. Gven a 3- CNF-SAT nstance F = C 1 C 2 C m, where C j s the dsjuncton of 3 varables, drawn form x 1, x 2,..., x l and x 1, x 2,..., x l. Construct graph G as follows: Frst, create a vertex wth capacty = 1 for each varable n each clause. Second, add an edge between two vertces correspondng the varables from the same clause. Fnally, add an edge between every par of vertces correspondng the varables x and x. Now, we use the black box of the decson problem to determne whether m brds can lve n G wthout fghtng. If they can, return yes. Otherwse, return no. (We do not requre the proof of correctness n ths homework problem. The proof s smlar to that of the reducton from 3-SAT to the maxmum ndependent set, whch s a well-known problem.) Let us check the tme complexty of the reducton. The frst and second steps run n O(m), and the last step runs n O(m 2 ). Therefore, 3-CNF-SAT s polynomal-tme reducble to the decson problem. 4. (3%) By the fact that 3-CNF-SAT s a known NP-complete problem and the polynomaltme reducton from 3-CNF-SAT to the decson problem, the decson problem s n NP-hard. Because the decson problem s n NP and NP-hard, the decson problem s a NP-complete problem. 2
Problem 3. MCS (15%) 1. (5%) Show that L NP Frst transform the problem nto decson problem that determne whether there s an nduced subgraph of both G 1 and G 2 wth edges k, a constant value. we can desgn an algorthm that verfy H s the nduced subgrapg of G, whch can be done n polynomal tme (O( H + mappng(v H V G )) = O(n)), so totally t takes polynomal to decde that H has edges k and H s nduced subgrapg of oth G 1 and G 2. Second we need to fnd the maxmum k to be the Maxmum Commom Subgraph, so we just need to do a for loop k = 0:mn( G 1, G 2 ) and the last teraton that the decson output yes s the maxmum k we want, so ts stll takes polynomal tme to fnd k. Then L NP. 2. (10%) Show that L NP -Hard To reduce the Maxmum Clque nto MCS, we just need to buld a new complete graph G, wth V G vertces (each 2 vertces have edge), then take the nput of Maxmum Clque, G, and G, as the nput of MCS, then we can get the maxmal k of 2 graphes, whch means that G has the maxmum clque wth vertces = k. To buld G only takes O( V G 2 ), so the reducton can be done n polynomal tme. Snce we know that Maxmum Clque s n NP -Complete, L NP -Hard. L NP and L NP -Hard L NP -complete. 3
A 2 for all possble y Problem 4. (15%) Show that any language n NP can be decded by an algorthm runnng n tme 2 O(nk) for some constant k. By the defnton of the class NP: A language L belongs to NP f and only f there exst a two-nput polynomal-tme algorthm A and a constant c such that L={x {0, 1} : there exsts a certfcate y wth y = O( x c ) such that A(x, y) = 1} Then algorthm A verfes L n polynomal tme. Therefore, for a language L n NP, we can desgn an algorthm A 2 that decdes L n tme 2 O(nk) for some constant k. f A(x, y) == 1: return 1 return 0 There are 2 y possbltes of y. y = O( x c ), therefore there are 2 O( x c) possbltes of y. And for every y, the algorthm runs A(x,y) once, n polynomal tme, O( x t ) for some constant t. So totally the runtme of the algorthm s 2 O( x c) O( x t ) = 2 O(nc) (c 2 n t ) = 2 O(nc) (2 log2c2+tlog2n ) = 2 O(nk ) 4
Problem 5. Vertex Cover(20%) 1. (4%) Fnd a mnmum vertex cover of the graph n Fgure 1. 2. No, there s no such constant k. For n N, defne G n = (V n, E n ). n V n = =0 V n, There are n! vertces n V n,0. For = 1, 2, 3,..., n, there are n! vertces n V n,. Each vertex n V n, are connected to vertces n V n,0 wthout duplcaton, so they are of degree. Therefore, every vertex n V n,0 s of degree n. The fgure of problem 5.1 s an example of G 3. The top 6 ponts are n V 3,1. The 6 ponts n the mddle are n V 3,0. The bottom left 2 ponts are n V 3,3. The bottom rght 3 ponts are n V 3,2. Snce our algorthm arbtrarly pck one of the vertces that has the greatest degree, t mght choose vertces n V n,n over V n,0, and V n,n 1 over V n,0, and so on. Our algorthm may choose all vertces n V n,n, V n,n 1, V n,n 2,..., V n,1 and none n V n,0. Therefore, we would have a n n! vertex cover of sze whle the mnmum vertex cover s V n,0. n n! n k (n!) k 1 whch would approach as n grows. 3. Yes. k = 2. By the defnton of vertex cover, f (u, v) E, at least one of u and v would be n V C. For every edge (u, v) we pcked durng the process, we add both u and v nto C and at least one of them would be n V C. Therefore, C 2 V C. 5