Week 17

Question

Click to Open Question

Check

  • Q1
  • Q2
  • Q3
  • Q4

Answer

Q1

  • LXS
題目

Let 2-CNF-SAT be the set of satisfiable Boolean formula in CNF with exactly 2 literals per clause. Show that 2-CNF-SAT ∈ P. Make your algorithm as efficient as possible. (Hint: Observe that x ∨ y is equivalent to ¬x → y. Reduce 2-CNF-SAT to an efficiently solvable problem on a directed graph.)

【解題思路】

將一個Boolean formula,其中有n個Boolean variable、m個calause,轉成一個directed graph,每個Boolean variable,

x1,...,xn對應圖中點
x1,¬x1,...,xn,¬xn
共2n個點,每個calause
xy
相當於
¬xy¬yx
,對於圖中我們也連接
¬xy
¬yx
共個點共2m個邊。

首先找strongly connected components,需要

O(n)時間,然後確保每個
xk
¬xk
不在同一個SCC(不能存在
xk...¬xk
¬xk...xk
),需要
O(n)
,如果在同一個S CC則該Boolean formula是Unsatisfiable的。

我們可以在多項式時間內決定2-CNF-SAT問題,因此2-CNF-SAT ∈ P.

找Assignment

假如我們把每個SCC視為一個點(同一個SCC塗同樣顏色)稱作

G,將每個點之間的邊的方向相反,稱作
GT
,在
GT
中,依照從原本
G
的Sink開始按照拓撲排序填色,相連的兩個SCC中填入相反的顏色,否則填入相同顏色,將同Sink顏色的點設為true即可以找到assignment。

Q2

  • xian
【題目】

The subgraph-isomorphism problem takes two undirected graphs G1 and G2, and it asks whether G1 is isomorphic to a subgraph of G2. Show that the subgraph-isomorphism problem is NP-complete.

【證明】

證明

SIPNPP

  • 假設我們有G1和G2的子圖G,從上禮拜作業已證明 GRAPH-ISOMORPHISM
    NP
    ,證明同構需要驗證以下四項:
    1. Equal number of vertices.
    2. Equal number of edges
    3. Same degree sequence
    4. Same number of circuit of particular length
  • 而這些都可以在
    P
    時間內驗證
  • 因此
    SIPNP

證明

SIPNP-hardCLIQUEpSIP

  • CLIQUEG2G1G1=Ki|G1|=ii|G2|
    ,問
    G2
    是否存在一個大小為
    k
    的完全子圖(cliqu)
    G
  • G2iCLIQUEG1G2
  • 因此將
    G1G2
    丟入
    SIP
    中,確認
    G1
    是否和
    G2
    同構
  • 如果同構則回答true,不同構則回答false

 G1  O(|G1|2)
CLIQUE
在指數時間下可解,則
SIP
也可
且我們已知
CLIQUENP-hard SIPNPSIPNP-hard

又因為

SIPNP-hard NP
 SIPNP-complete#

Q3

  • chung
【題目】

Given an integer m x n matrix A, and an integer m-vector b, the 0-1 integer-programming problem asks whether there exists an integer n-vector x with elements in the set {0, 1} such that Ax ≤ b. Prove that 0-1 integer programming problem is NP-complete. (Hint: Reduce from 3-CNF-SAT.)

【證明】

  • Problem ∈ NP : Find a certificate to verify that it is the correct answer to this question.

    • A certificate would be the n-vector x, and we can verify in polynomial time that Ax ≤ b, so 0-1 integer linear programming (01LP) is in NP.
  • Problem ∈ NP-hard : 3-CNF-SAT

    𝑝 0-1 integer- programming problem

    • 3-CNF-SAT
      Ex:(𝑥1𝑥2𝑥3)(𝑥1¬𝑥3¬𝑥4)

      If
      𝑥𝑗
      in clause i with negation →
      𝐴(𝑖,𝑗)=1

      If
      𝑥𝑗
      in clause i without negation →
      𝐴(𝑖,𝑗)=1

      Other,
      𝐴(𝑖,𝑗)=0

      𝑏𝑖
      = – 1 + num of negation in clause i
      (𝑥1𝑥2𝑥3):𝑥1+𝑥2+𝑥31𝑥1𝑥2𝑥31(𝑥1¬𝑥3¬𝑥4):𝑥1+(1𝑥3)+(1𝑥4)1𝑥1+𝑥3+𝑥41Axb:[11101011]𝜒[11]

      轉換時間在 polynomial time 內,其又為 NP Problem,故得證 0-1 integer- programming problem is NP-complete.

Q4

  • yee
【題目】

Based on hw14-7,we know that longest-simple-cycle problem is an NP-problem.
Prove that the problem is NP-complete

【解題思路】
由14-7我們知道LSC為NP問題,

certificate依序為
v1,v2,v3,...,vk
,且已知Hami-cycle 為NP-complete問題,因此可由Hami-cycle reduce to LSC 來證明LSC也是NP-complete問題。

【證明】

Hamicycle<=pLSC

若一Graph存在一個Hami-cycle也代表該Graph存在一k = |V|的LSC,若一Graph存在一序列

v1,v2,v3,...,vn(n=|V|)的LSC,也代表該Graph也存在一Hami-cycle,因此可知Hami-cycle\ \ iff.\ LSC
 LSCNP-complete#