Consider the language GRAPH-ISOMORPHISM $ = \{ \langle G_1, G_2 \rangle : G_1$ and
$G_2$ are isomorphic graphs$\}$. Prove that GRAPH-ISOMORPHISM$\in$ NP by describing a polynomial-time algorithm to verfify the language.
The certificate should be a mapping
For any
Show that if HAM-CYCLE
$\in$ P, then the problem of listing the vertices of a hamiltonian cycle, in order, is polynomial-time solvable.
For every vertex
Prove that the class NP of languages is closed under union, intersection, concatenation, and Kleene star. Discuss the closure of NP under complement.
- Union
IF A_1(x, y) == 1 || A_2(x, y) == 1
THEN RETURN TRUE
ELSE RETURN FALSE
- Intersection
IF A_1(x, y) == 1 && A_2(x, y) == 1
THEN RETURN TRUE
ELSE RETURN FALSE
- Concatenation
FOR i = 1 .. n
FOR j = 1 .. m
IF A_1(x_1 ... x_i, y_1 ... y_j) == 1 && A_2(x_i+1 ... x_n, y_j+1 ... y_m) == 1
THEN RETURN 1
RETURN 0
- Kleene star
IF x == epsilon
THEN RETURN 1
FOR i = 1 .. n
FOR j = 1 .. m
DP[i, j] = 0
DP[0, 0] = 1
FOR i = 0 .. n
FOR j = 0 .. m
FOR k = i + 1 .. n
FOR l = j + 1 .. m
IF A_1(x_i ... x_k, y_j .. y_l) == 1
THEN DP[k, l] = 1
RETURN DP[n, m]
Show that any language in NP can be decided by an algorithm running in time
$2^{O(n^k)}$ for some constant$k$ .
FOR all possible y
IF A(x, y) == 1
THEN RETURN 1
RETURN 0
A hamiltonian path in a graph is a simple path that visits every vertex exactly once. Show that the language HAM-PATH$={\langle G, u, v \rangle:$ there is a hamiltonian path from
$u$ to$v$ in graph$G\}$ belongs to NP.
Suppose
- $ n = |G| $
- $ v_1 = u $
- $ v_n = v $
- $ \forall i \in \{1, \dots, n\}, v_i \in V $
- $ \forall i \in \{1, \dots, n - 1\}, j \in \{i + 1, \dots, n\}, v_i \ne v_j $
- $ \forall i \in \{1, \dots, n - 1\}, (v_i, v_{i+1}) \in E $
Show that the hamiltonian-path problem from Exercise 34.2-6 can be solved in polynomial time on directed acyclic graphs. Give an efficient algorithm for the problem.
Find the longest path from
Let
$\phi$ be a boolean formula constructed from the boolean input variables$x_1, x_2, \dots, x_k$ , negations($\neg$ ), ANDs($\wedge$ ), ORs($\vee$ ), and parentheses. The formula$\phi$ is a tautology if it evaluates to 1 for every assignment of 1 and 0 to the input varibales. Define TAUTOLOGY as the lanuage of boolean formulas that are tautologies. Show that TAUTOLOGY$\in$ co-NP.
The certificate is a set of assignments of 0s and 1s to $x$s. Since it takes
Prove that
$\text{P} \subseteq \text{co-NP}$ .
Prove that if
$\text{NP} \ne \text{co-NP}$ , then$\text{P} \ne \text{NP}$ .
Prove the contrapositive.
Suppose
-
$\forall L \in \text{NP}$ $\Rightarrow$ $L \in \text{P}$ $\Rightarrow$ $\overline{L} \in \text{P}$ $\Rightarrow$ $L \in \text{co-NP}$ -
$\forall L \in \text{co-NP}$ $\Rightarrow$ $\overline{L} \in \text{NP}$ $\Rightarrow$ $\overline{L} \in \text{P}$ $\Rightarrow$ $L \in \text{P}$ -
$\Rightarrow$ $\text{NP} = \text{co-NP}$ .
Let
$G$ be a connected, undirected graph with at least 3 vertices, and let$G^3$ be the graph obtained by connecting all pairs of vertices that are connected by a path in$G$ of length at most 3. Prove that$G^3$ is hamiltonian.
Let
We can prove
For
Suppose
$|T_v.V| = 1$
The distance between
$|T_v.V| = 2$
The distancce between
$|T_v.V| \ge 3$
Same as