算法代写｜CSE 347 Analysis of Algorithms Homework 6 Solutions

这是一篇来自美国的家庭作业**算法代写**

- We fifirst argue that the professor’s challenge is in NP. A certifificate for a true instance of the problem is a set of stones to remove (equivalently, a set to leave in place). Such a certifificate has size at most
*r**×**c*so is polynomial in the problem size. Given such a certifificate, we simply verify that every row has at least one stone, and that no column has stones of two difffferent colors.

To show that the challenge is NP-hard, we reduce from 3SAT. Let *φ *be a formula with *m *clauses and *n *variables. We create an UltraGo board with *m *rows and *n *columns. For each clause *c**j *of *φ*, if variable *x**i *appears in a literal of *c**j *, we place a stone at row *j *and column *i*. If *x**i *appears negated,the stone is black; otherwise, it is white. (WLOG, we can discard any clause in which *x**j *appears both negated and non-negated, since such a clause is trivially satisfified by any truth assignment.) Clearly,this construction can be completed in time proportional to the number of clauses.

**Claim: ***φ *is satisfifiable iffff our constructed UltraGo board has a challenge solution.

**Pf: **(*→*) let *A *be a satisfying assignment to *φ*. In each clause *c**j *of *φ*, choose any one literal made true by *A *and leave its stone in place; remove the other two stones from row *j*. *A *makes every clause true,so this process will leave (exactly) one stone in every row.

*A *makes every variable either true or false, so no two clauses can have true literals *x**i *and *¬**x**i *. Hence,every occurrence of a stone in row *i *is either white (if *A *sets *x**i *true) or black (if *A *sets *x**i *false).

Hence, the board has a solution to the challenge.

(*←*) suppose our board has a solution to the challenge. For each variable *x**i *of *φ*, if the solution leaves only white stones in row *i*, set *x**i *true; if it leaves only black stones, set *x**i *false; if no stones are left in row *i*, set *x**i *arbitrarily.

We fifirst note that the resulting truth assignment makes every variable either true or false. Moreover,every row has at least one stone. By construction, a stone is placed in cell (*j, i*) only if the specified assignment to variable *x**i *makes the corresponding clause *c**j *true. Hence, if there is a stone remaining in each row, then each clause has at least one true literal, and so *φ *is satisfified.

- We will prove the NP-completeness of the canonical decision problem, which is: given the graph of bars with designated start and end and the list of forbidden pairs, is there a crawl of length at least
*k*?

We fifirst argue that this problem, CRAWL, is in NP. A certifificate for a true instance is a crawl,represented as a list of bars visited in order. This crawl has size at most that of the input graph. To validate the certifificate, we check that it starts and ends with the correct pubs, that it does match some simple path in the graph, and that, for each forbidden pair of bars, the path does not include both of them. The total cost of the validator is bounded asymptotically by the number of conflflicting pairs times the graph size, which is polynomial in the input size.

We now argue that 3-SAT *≤**p *CRAWL. Given an instance *φ *of 3-SAT, we construct a graph *G *and forbidden pairs for CRAWL as follows. Suppose *φ *has *m *clauses, and let *C**i *be the *i*th clause of *φ *with literals *` **i*1 *, `**i*2 *, `**i*3 . We add to the graph three vertices *v*1*i **, v**i*2*, v**i*3. We also add two distinguished vertices *s *and *t *to the graph. We add edges from every vertex built from *C**i *to every vertex built from *C**i*+1,as well as from *s *to every vertex built from *C*1 and from every vertex built from *C**m *to *t*. This graph is clearly a DAG of size proportional to *|**φ**| *and can be built in time proportional to its size.

We designate as a forbidden pair any two vertices *v*, *v**0 *whose corresponding literals *`, `**0 *are logical negations of each other. There are at most *|**φ**|*2 such pairs, which can be found in time proportional to their number.

**Claim 1**: if *φ *is satisfifiable, then there is a crawl through graph *G *of length *m *+ 2 that does not use any forbidden pair.

**Pf**: Let *A *be a satisfying assignment for *φ*. *A *makes at least one literal of every clause true. Choose true literals *` *1 *. . . `**m*, one from each clause. The corresponding crawl in *G *is *s, v*1 *. . . v**m**, t*, where *v**j *is the vertex corresponding to literal *` **j *. This is clearly a valid path from *s *to *t *in *G*. Moreover,since *A *simultaneously makes all the literals *` *1 *. . . `**m *true, no two of these literals can be logically contradictory, and so the path has no forbidden pairs.

**Claim 2**: if *G *has a crawl of length *m*+2 with no forbidden pairs, then there is a satisfying assignment for *φ*.

**Pf**: Let *π *be the crawl through *G *of the given length. By the structure of *G*, *π *has the form *s, v*1 *. . . v**m**, t*, where *v**j *is a vertex corresponding to a literal *` **j *from clause *C**j *. Construct a truth assignment *A *by choosing the variables so as to make every literal *` **j *from this path true (setting any remaining variables arbitrarily). Because *A *induces one true literal in each clause of *φ*, it satisfifies *φ*.

Moreover, *A *must exist because path *π *uses no forbidden pairs, and so no two literals induced by the path are logically contradictory.

You may also like:

2023年9月15日 作业代写

报告代写,作业代写,需求代写|Needs assessment report 2023年9月15日 作业代写

作业代写,报告代写
扫描二维码或者

添加微信skygpa

添加微信skygpa