Algo Test 2 (NP-Complete)

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Reducing from a arbitrary instance of known problem to an instance of an unknown is

*FINE*

Reducing instances of known problem to general instances of unknown is

*NO GOOD* Perhaps the instances of the known that we chose to reduce from were "easy", and so we would not have reduced an NP-hard problem to CLIQUE.

Define Traveling Sales Person Problem

A salesman must visit n cities. Modeling the problem as a complete graph with n vertices, we can say that the salesman wishes to make a tour, or hamiltonian cycle, visiting each city exactly once and finishing at the city he starts from. The salesman incurs a nonnegative integer cost c(i, j) to travel from city i to city j, and the salesman wishes to make the tour whose total cost is minimum, where the total cost is the sum of the individual costs along the edges of the tour.

Define a vertex cover

A vertex cover of an undirected graph G = (V, E) is a subset V' in V such that if (u, v) in E, then u is in V' or v is in V' (or both). That is, each vertex "covers" its incident edges, and a vertex cover for G is a set of vertices that covers all the edges in E. The size of a vertex cover is the number of vertices in it.

Give an example of such a problem, or state that no such example exists An NP-complete problem, not known to be in P.

All NP-complete problems are defined such that a polynomial solution is unknown. So one example would be 3-CNF satisfiability.

Show Hamiltonian-cycle problem is in NP

Given a directed graph G D .V; E/, a certificate would be a sequence {v1, v2, v3, v|v| of |V | vertices. We could easily check in polynomial time that. We can easily check in polynomial time if that sequence satisfies the definition of a Hamiltonian cycle.

If any NP-complete problem can be solved in polynomial time, then

If any NP-complete problem can be solved in polynomial time, then *every problem in NP has a polynomial-time algorithm.

Finding the longest simple path between two vertices is

NP-complete

if any NP-complete problem can be solved in polynomial time, then _________________________

if any NP-complete problem can be solved in polynomial time, then *every problem in NP has a polynomial-time solution, that is, P = NP.*

if any problem in NP is not polynomial-time solvable, then *no NP-complete problem is polynomial-time solvable.*

if any problem in NP is not polynomial-time solvable, then *no NP-complete problem is polynomial-time solvable.*

We can't entire prove that a particular problem is

intractable

Define the vertex problem

is to find a vertex cover of minimum size in a given graph. Restating this optimization problem as a decision problem, we wish to determine whether a graph has a vertex cover of a given size k.

Informally, a problem is in the class NPC if

it is in NP and is as "hard" as any problem in NP.

Define clique problem

the optimization problem of finding a clique of maximum size in a graph. As a decision problem, we ask simply whether a clique of a given size k exists in the graph.

Prove the clique problem is NP-complete

1. Show CLIQUE is in NP. For a given graph G = (V, E), we use the subset V' in V of vertices in the clique as a certificate for G. We can check whether V' is a clique in polynomial time by checking whether, for each pair u, v in V', the edge (u,v) belongs to E. 2. Reduce from 3-CNF-SAT 3. Suppose you have a boolean formula in 3-CNF with k clauses. Each clause has exactly 3 literalss. Construct a graph G such that the boolean is satisfiable if and only if G has a clique of size k. For each clause in the boolean, we place a triple of vertices v1, v2, v3 into V. 4. Show that this transformation of boolean into G is a reduction. First, suppose that boolean B has a satisfying assignment. Then each clause contains at least one literal that is assigned. Picking one such "true" literal from each clause yields a set V' of k vertices. We claim that V' is a clique. For any two vertices in V' that are not the same, both corresponding literals map to 1 by the given satisfying assignment, and thus the literals cannot be complements. Thus, by the construction of G, the edge vi vj belongs to E. Conversely (go the other way), suppose that G has a clique V' of size k. No edges in G connect vertices in the same triple, and so V' contains exactly one vertex per triple. we can assign 1 to each literal such that v is in V' iwthout fear of assigning 1 to both a literal and its complement, since G contains no eges between inconsistent literals. Each clause is satisfied, and so B is satisfied. 5. Mapping can be done in Polynomial time.

Prove the hamiltonian cycle problem is NP-complete.

1. Show Ham-Cycle belongs in NP. Given a graph G = (V, E), our certificate is the sequence of |V| vertices that makes up the hamiltonian cycle. the verification algorithm checks that this sequence contains each vertex in V exactly once and that with the first vertex repeated at the end, it forms a cycle in G. That is, it checks that there is an edge between each pair of consecutive vertices and between the first and last vertices. We can verify the certificate in polynomial time. 2. We prove NP-complete by proving that VERTEX-COVER <= HAM-CYCLE 3. Complicated as heck

Steps to proving NP-completeness:

1. Prove it is in NP 2. Select a known NP-complete problem. 3. Describe a method that maps every instance of the known problem to the unknown problem. 4. Prove that the function satisfies in all elements in the known if and only if it also satisfies in all elements of the unknown. Go both ways! 5. Prove that the algo computing function runs in polynomial time

Give an example of such a problem, or state that no such example exists A problem in NP, not known to be in P

Any NP-complete problem which must be NP but have yet to figure out of they are solvable in polynomial time.

Define the complexity class NP

The complexity class NP is the class of languages that can be verified by a polynomial-time algorithm.

Show 3-CNF satisfiability is in NP

a certificate would be an assignment of values to variables. We could check in polynomial time that this assignment satisfies the boolean formula.

Prove the vertex-cover problem is NP-complete.

1. Show VERTEX-COVER is in NP. Suppose we are given a graph G = (V, E) and an integer k. The certificate we choose is the vertex cover V' in V itself. The verification algorithm affirms that |V'| = k, and then it checks, for each edge (u, v) in E, that u in V' or v in V'. We can easily verify the certificate in polynomial time. 2. We prove that the vertex-cover problem is NP-hard by showing that CLIQUE <= VERTEX-COVER. 3. This reduction relies on the notion of the "complement" of a graph. Given an undirected graph G = (V, E), we define the complement of G as notG = (V, notE), where notE = {(u,v): u,v in V, u not= v, and (u, v) not in E}. In other words, notG is the graph containing exactly those edges that are not in G. The reduction algorithm takes as input an instance <G, k> of the clique problem. It computes the compliment notG, which we can easily do in polynomial time. The output of the reduction algorithm is the instance <G, |V| - k> of the vertex-cover problem. to complete the proof, we show that this transformation is indeed a reduction: the graph G has a clique of size k if and only if the graph notG has a vertex cover of size |V| - k. 4. Suppose that G has a clique V' in V with |V'| = k. We claim that V - V' is a vertex cover in notG. Let (u, v) be any edge in notE. Then, (u, v) not in E, which implies that at least one of u or v does not belong to V', since every pair of vertices in V' is connected by an edge of E. Equivalently, at least one of u or v is in V - V', which means that edge (u, v) is covered by V - V'. Since (u, v) was chosen arbitrarily from notE, every edge of notE is covered by a vertex in V-V'. Hence, the set V-V', which as size |V| -k, forms a vertex cover for notG. Conversely, suppose that notG has a vertex cover V' in V, where |V'| = |V| - k. Then, for all u, v in V, if (u,v) in not E, then u in V' or v in V' or both. The contrapositive of this implication is that for all u, v in V, if u not in V' and V not in V', then (u, v) is in E. In other words, V-V' is a clique, and it has size |V| - |V'| = k.

Prove the traveling-salesman problem is NP-complete.

1. We first show that TSP belongs to NP. Given an instance of the problem, we use a certificate the sequence of n vertices in the tour. The verification algorithm checks that this sequence contains each vertex exactly once, sums up the edge costs, and checks whether the sum is at most k. This process can certainly be done in polynomial time. 2. To prove that TSP is NP-hard, we show that HAM-CYCLE <= TSP. 3. Construction: Let G = (V, E) be an instance of HAM-CYCLE. We construct an instance of TSP as follows. We form the complete graph G' = (V, E'), where E'), where E' = {(i, j) : i, j in V and i not equal j}, and we define the cost function c by c(i, j) = { 0 if (i, j) in E, 1 if (i,j) not in E. (Note that because G is undirected, it has not self-loops, and so c(v, v) = 1 for all vertices v in V.) The instance of TSP is then <G', c, 0>, which we can easily create in polynomial time. 4. We now show that graph G has a hamiltonian cycle if and only if graph G' has a tour of cost at most 0. Supose that graph G has a hamiltonian cycle h. Each edge in h belongs to E and thus has cost 0 in G'. Thus, h is a tour in G' with cost 0. Conversely, suppose that graph G' has a tour h' of cost at most 0. Since the costs of the edges in E' are 0 and 1, the cost of tour h' is exactly 0 and each edge on the tour must have cost 0. Therefore, h' contains only edges in E. We conclude that h' is a hamiltonian cycle in graph G.

A boolean formula contains variables whose values are 0 or 1; boolean connectives such as AND OR NOT and parentheses. A boolean formula is satisfiable if there exists some assignment of the values 0 and 1 to its variables that causes it to evaluate to 1. A boolean formula is in k-conjuctive normal form, or k-CNF, if it is the AND of clauses of ORs of exactly k variables or their negations. 2-CNF is ____________ 3-CNF is ____________

2-CNF is *solvable in polynomial time* 3-CNF is NP-complete

Any problem in P is also ....

Any problem in P is also *in NP*, since if a problem is in P then we can solve it in polynomial time without even being supplied a certificate.

Give an example of such a problem, or state that no such example exists A problem in P, not known to be in NP

Any problem in P is also in NP, so doesn't exist

Bipartite Graph

Consists of two sets of vertices X and Y. The edges only join vertices in X to vertices in Y, not vertices within a set.

Give an example of such a problem, or state that no such example exists An NP-complete problem, not known to be in NP.

Doesn't exist. To prove NP-completeness you have to first show its in NP.

If you prove that a particular instance of a problem is NP-complete, then ...

If you prove that a particular instance of a problem is NP-complete, then *it is NP-complete in the general case but not the other way.*

Define Clique

In an undirected graph G = (V, E) is a subset V' <- V of vertices, each pair of which is connected by an edge in E. In other words, a clique is a complete subgraph of G. The size of a clique is the number of vertices it contains.

In other words, by "reducing" solving problem A to solving problem B, we _________________

In other words, by "reducing" solving problem A to solving problem B, we *use the "easiness" of B to prove the "easiness" of A.*

How to use a polynomial-time reduction algorithm to solve a decision problem A in polynomial time, given a polynomial-time decision algorithm for another problem B?

In polynomial time, we transform an instance ˛alpha of A into an instance betaˇ of B, we solve B in polynomial time, and we use the answer for betaˇ as the answer for alpha In other words, 1. Given an instance alpha of problem A, use a polynomial-time reduction algorithm to transform it to an instance beta of problem B. 2. Run the polynomial-time decision algorithm for B on the instance B. 3. Use the answer for Beta as the answer for Alpha.

Intuitively, a problem Q can be reduced to another problem Q' if ____________________________

Intuitively, a problem Q can be reduced to another problem Q' if *any instance of Q can be "easily rephrased" as an instance of Q', the solution to which provides a solution to the instance of Q.*

Bin packing problem

Items of different volumes must be packed into a finite number of bins or containers each of a fixed given volume in a way that minimizes the number of bins used. The decision problem (deciding if items will fit into a specified number of bins) is NP-complete

A hamiltonian cycle of a directed graph G = (V, E) is a simple cycle that contains each vertex in V. Determining whether a directed graph has a hamiltonian cycle is

NP-complete

NP-completeness applies directly not to ______________ problems, however, but to ___________________ problems, in which the answer is _________________

NP-completeness applies directly not to *optimization* problems, however, but to *decision* problems, in which the answer is *simply "yes" or "no" (or, more formally, "1" or "0").*

Give an example of such a problem, or state that no such example exists A problem in P, not known to be NP-complete

No such example exists. No NP-complete problem has been verified to be solvable in polynomial time.

Polynomial-time solvable problems are regarded as tractable. 3 support arguments:

Polynomial-time solvable problems are regarded as tractable. 3 support arguments: -Experience has shown that once the first polynomial-time algorithm for a problem has been discovered, more efficient algorithms often follow. Even if the current best algorithm for a problem has a running time of theta(n^100) an algorithm with a much better running time will likely soon be discovered. -Second, for many reasonable models of computation, a problem that can be solved in polynomial time in one model can be solved in polynomial time in another. -the class of polynomial-time solvable problems has nice closure properties, since polynomials are closed under addition, multiplication, and composition.

Prove Satisfiability of boolean formulas is in NP.

Show SAT belongs to NP. we show that a certificate consisting of a satisfying assignment for an input formula f can be verified in polynomial time. The verifying algorithm simply replaces each variable in the formula with its corresponding value and then evaluates the expression. This task is easy to do in polynomial time. If the expression evaluates to 1, then the algorithm has verified that the formula is satisfiable. Thus, SAT is in NP.

Stated in a way that has more relevance to NP-completeness, if we can provide evidence that a decision problem is hard, we also provide evidence that ____________________. Thus, even though it restricts attention to decision problems, the theory of NP-completeness often has implications for ________________

Stated in a way that has more relevance to NP-completeness, if we can provide evidence that a decision problem is hard, we also provide evidence that *its related optimization problem is hard*. Thus, even though it restricts attention to decision problems, the theory of NP-completeness often has implications for *optimization problems as well. *

Define Class NP

The class NP consists of those problems that are "verifiable" in polynomial time. What do we mean by a problem being verifiable? If we were somehow given a "certificate" of a solution, then we could verify that the certificate is correct in time polynomial in the size of the input to the problem.

Define Class P

The class P consists of those problems that are solvable in polynomial time. More specifically, they are problems that can be solved in time O(n^k) for some constant k, where n is the size of the input to the problem. Most of the problems examined in previous chapters are in P.

Define the complexity class P

The set of concrete decision problems that are polynomial-time solvable.

Give an example of such a problem, or state that no such example exists A problem in NP, not known to be NP-complete

This assumes P does not equal NP which has not be proved. If P did not equal NP then there could be a class of NP problems that are neither P nor NP-complete.

To prove NP-completeness, you can go from 3-CNF-SAT --> ...

To prove NP-completeness, you can go from 3-CNF-SAT --> *Clique --> Vertex-Cover --> Ham-Cycle --> TSP* And of course from different instances. Ex: From 3 colorable to 4 colorable

Define Subset-Sum Problem

We are given a finite set S of positive integers and an integer target t > 0. We ask whether there exists a subset S' in S whose elemtns sum to t. For example, if S = {1, 2, 7, 14, 49, 98, 343, 686, 2409, 3793, 16808, 17206, 117705, 117993} and t = 138457, then the subset S' = {1, 2, 7, 98, 343, 686, 2409, 17206, 117705} is a solution. You can prove NP-C by reducing from 3-CNF

In the partition problem, you are given a set of numbers, and you want to know whether the numbers can be divided into 2 groups such that each group sums to the same value as the other group, i.e. half of the total weight. Either show that partition is NP-complete given that bin packing is NP-complete, or show that bin packing is NP-complete given that partition is NPcomplete. Make clear which of these problems you are solving. One of them is much harder than the other, so I do not recommend that you do both!

We will show Bin packing is NP-complete given that partition is. 1. Show BIN is in NP. Given the optimal number of bins to pack the items in, we can verify in polynomial time whether the # of bins in the certificate is the same as the optimal solution 2. We will reduce the known Partition problem to the BIN problem. 3. Construction: Consider the partition G. We're given a set of numbers 1-n and 2 partitions. To make BIN problem G', we take numbers in G as items with the numbers representing weights and where there are 2 bins and the capacity of either is sum / 2. 4. We now show that graph G has a hamiltonian cycle if and only if graph G' has a tour of cost at most 0 We now show that G has numbers that can be into 2 groups of equal value if and only if the items fit in 2 bins in G'

When we demonstrate that a problem is NP-complete, we are making a statement about ____________________ rather than about *how easy it is*. We are not trying to prove______________________, but instead that ___________________

When we demonstrate that a problem is NP-complete, we are making a statement about *how hard it is (or at least how hard we think it is),* rather than about *how easy it is*. We are not trying to prove* the existence of an efficient algorithm*, but instead that *no efficient algorithm is likely to exist.*

Verify Hamiltonian cycle is in NP

simply verify that the provided cycle is hamiltonian by checking whether it is a permutation of the vertices of V and whether each of the consecutive edges along the cycle actually exists in the graph.

Finding the shortest path from a single source in a direct graph G = (V, E) is

solvable in polynomial time

An Euler tour of a strongly connected, directed graph G = (V, E) is a cycle that traverses each edge of G exactly once, although it is allowed to visit each vertex more than once. This is

solvable in polynomial time. We can find the edges of the Euler tour in O(E) and determine if a graph has one in O(E)


Kaugnay na mga set ng pag-aaral

Quiz 2 Chapter 2 "Economics & Business"

View Set

Module 14 Review Quiz: Linux installation and configuration

View Set

english study questions (of mice of men)

View Set

Chapter 9 - Teaching and Counseling

View Set