TSP
Input: A matrix of distances; a budget b
Output: A tour which passes through all the cities and has length ≤ b, if
such a tour exists.
The optimization version of this problem asks directly for the shortest tour.
TSP-OPT
Input: A matrix of distances
Output: The shortest tour which passes through all the cities.
Show that if TSP can be solved in polynomial time, then so can TSP-OPT.
證明:若 S 爲圖G 中所有邊的長度之和,顯然所求最短迴路的長度不會超過 S 。倘若 TSP
能在多項式時間內解決,那麼通過在區間[0, S]內二分的進行 TSP 詢問,從而也就
能在多項式時間內解決 TSP-OPT。
8.2. Search versus decision. Suppose you have a procedure which runs in polynomial
time and tells you whether or not a graph has a Rudrata path. Show that you can
use it to develop a polynomial-time algorithm for RUDRATA PATH (which returns
the actual path, if it exists).
證明:如果圖G 中存在哈密頓迴路(亦即是 Rudrata path),那麼對於圖G 中的每一條邊 e ,
詢問G 除去邊 e 後是否還存在哈密頓迴路。如果答案是“否”,說明 e 正好是迴路中
的一條邊。如果答案是“是”,則將 e 中從圖G 中去掉。在上述過程完成之後,圖G
中剩餘的邊即是所求的迴路。顯然,若每次詢問都是多項式時間的,那麼整個過程
可以在多項式時間內完成。
8.3STINGY SAT is the following problem: given a set of clauses (each a disjunction of
literals) and an integer k, find a satisfying assignment in which at most k
variables are true, if such an assignment exists. Prove that STINGY SAT is
NP-complete.
證明:首先,易知 STINGY SAT 的解是可在多項式時間內驗證的,因此屬於 NP。另外,
很容易可以將 SAT 歸約到 STINGY SAT(將 k 設爲所有變量的總個數即可),於是可
知 STINGY SAT 爲 NP 完全問題
8.4Consider the CLIQUE problem restricted to graphs in which every vertex has
degree at most 3. Call this problem CLIQUE-3.
(a) Prove that CLIQUE-3 is in NP
(b) What is wrong with the following proof of NP-completeness for CLIQUE-3?
We know that the CLIQUE problem in general graphs is NP-complete, so it
is enough to present a reduction from CLIQUE-3 to CLIQUE. Given a graph G
with vertices of degree ≤ 3, and a parameter g, the reduction leaves the
graph and the parameter unchanged: clearly the output of the reduction
is a possible input for the CLIQUE problem. Furthermore, the answer to
both problems is identical. This proves the correctness of the reduction
and, therefore, the NP-completeness of CLIQUE-3.
(c) It is true that the VERTEX COVER problem remains NP-complete even when
restricted to graphs in which every vertex has degree at most 3. Call this
problem VC-3. What is wrong with the following proof of
NP-completeness for CLIQUE-3?
We present a reduction from VC-3 to CLIQUE-3. Given a graph G = (V, E)
with node degrees bounded by 3, and a parameter b, we create an
instance of CLIQUE-3 by leaving the graph unchanged and switching the
parameter to |V| - b. Now, a subset C ⊆ V is
a vertex cover in G if and
only if the complementary set V - C is a clique in G. Therefore G has
a
vertex cover of size ≤ b if and only if it has a clique of size ≥ |V|
- b.
This proves the correctness of the reduction and, consequently, the
NP-completeness of CLIQUE-3.
(d) Describe an O(|V|) algorithm for CLIQUE-3.
證明:a) 顯然 CLIQUE-3 的解是可以多項式時間內驗證的,於是屬於 NP。
b) 歸約的方向反了,應該是 CLIQUE→ CLIQUE-3,而不是 CLIQUE-3→ CLIQUE。
c) 注意求出G 的團之後只能得到G 的頂點覆蓋,而非G 的頂點覆蓋。
d) 若圖G 中所有的頂點的度不大於 3,那麼可知在圖G 的最大團中不會超過 4 個
頂點。於是,直接枚舉所有的頂點四元組即可求解,時間複雜度爲O (|V|^4) 。
8.7. Consider a special case of 3SAT in which all clauses have exactly three literals,
and each variable appears exactly three times. Show that this problem can be
solved in polynomial time. (Hint: Create a bipartite graph with clauses on the
left, variables on the right, and edges whenever a variable appears in a clause.
Use Exercise 7.30 to show that this graph has a matching.)
證明:按提示構造二分圖G 。因爲每個子句( clause)恰好包含三個文字( literal),所以任
意 n 個子句總共包含了3n 個文字(可能有重複)。又因每個變量最多對應三個文字,
所以這3n 個文字至少對應了 n 個變量。於是在圖G 中,任意 n 個子句都與不少於 n
個變量相連,由 Hall 定理知圖G 存在完美匹配。找出一個完美匹配,假設子句 c 與
變量 v 配對,若 c 中包含了 v 的肯定,則將 v 設爲 true,若 c 包含了 v 的否定,則將 v
設爲 false,若 c 同時包含了 v 的肯定及否定,那麼 v 可以任意取值。分別爲每個配
對進行上述賦值過程,即可找到一組可滿足解。
8.8. In the EXACT 4SAT problem, the input is
a set of clauses, each of which is a
disjunction of exactly four literals, and such that each variable occurs at most
once in each clause. The goal is to find a satisfying assignment, if one exists.
Prove that EXACT 4SAT is NP-complete.
證明:首先很顯然, EXACT 4SAT 屬於 NP。現在通過將 3SAT 歸約到 EXACT
4SAT 來證
明後者的 NP 完全性。對於任意一個 3SAT 實例,如果其中某個子句中包含了同一個
文字多次,那麼可以縮減爲一次,如果同時包含了某個變量的肯定及否定,那麼可
以將這個變量去掉。然後,可以再在每個子句中可以添加一些啞變量(即沒用的輔
助變量),這樣就可以將每個子句所包含的文字數目擴充到四個。至此,即已將該
3SAT 實例轉化成了一個 EXACT 4SAT 問題