- LXS
Show that any comparison-based algorithm needs time to solve the
following problem: Given n points in the 2D plane, construct a tree of minimum
total length whose vertices are the given points and the edge length of an edge is
the Euclidean distance between the two end points of the edge.
首先 reduce sorting 問題到 EMST(euclidean minimum spanning tree) 問題。
假如sorting問題的輸入是x1, x2, x3,…,存在一個對應的EMST問題,其中每個點的座標是(x1,x1), (x2,x2), … ,每個輸入重複兩次,轉換的時間只要,EMST的答案中樹的兩端點是最大端與最小端,從隨意一端開始輸出,的時間可以轉回sorting的答案,基於比較的排序演算法下界,所以我們可以說,任何基於排序的演算法要。
- chung
Show that if an algorithm makes at most a constant number of calls to polynomial-time subroutines and performs an additional amount of work that also takes polynomial time, then it runs in polynomial time. Also show that a polynomial number of calls to polynomial-time subrountines may result in an exponential-time algorithm
【題目說明】
在⼀個演算法中,呼叫常數次subroutines(Polynomial time),此外subroutines間的input與output互相牽動著,則其演算法時間複雜度也為 polynomial time
【證明】
運用數學歸納法證明,假設呼叫n次subroutines,
當n=1時,total time is polynomial成立
假設當n=k時,total time is polynomial成立
Consider n = k+1,
k+1次subroutines的total time
= 呼叫k次subroutines的total time + 呼叫1次subroutines的total time
= polynomial time + polynomial time(根據上述假設)
= polynomial time
因此n=k+1時,total time is polynomial亦成立,故得證
假設子程式總共有 個,其中複雜度最高為
多做的事情複雜度為
則子程式們總複雜度最多為
加上多做的事情,複雜度仍為
因為 為常數,所以這還是 polynomial
【題目說明】
若呼叫polynomial次subroutines,則時間複雜度可能變為exponential-time
【證明】
假設
故呼叫polynomial次subroutines,時間複雜度可能變為exponential time,得證
- LXS
Show that the class P, viewed as a set of languages, is closed under union, intersection, concatenation, complement, and Kleene star. That is, if , then , , , , and .
可以被機器在多項式時間內決定,設計一台機器輸入為,用以決定,分別對輸入,如果或被接受時接受,否則拒絕。
最糟情況下的時間複雜度為
得出的語言也就是
前提假設同上,設計一台機器輸入為,只在都被接受時接受,否則拒絕。
最糟情況下的時間複雜度為
得出的語言也就是
前提假設同上,設計一台機器輸入為
對於輸入,對輸入,當接受則接受。
若for迴圈中沒有使接受,則拒絕。
時間複雜度為
設計一台輸入為,對輸入,若拒絕則輸出接受,反之拒絕,反轉輸出時間仍為,得。
時間複雜度為:
得
- xian
Show that if HAM-CYCLE ∈ P, then the problem of listing the vertices of a hamiltonian cycle, in order, is polynomial-time solvable.
(Note 1: HAM-CYCLE is defined as "Does a graph G have a Hamiltonian cycle?")
(Note 2: "HAM-CYCLE ∈ P" means that HAM-CYCLE is polynomial-time solvable.)
【解題思路】
Hamiltonian cycle定義為存在一個環包含所有頂點,且每個頂點只能被走過一次 因為已知 HAM-CYCLE ∈ P,因此我們可以利用此演算法解題。
【蘇都扣】
【結論】
HAM-CYCLE ∈ P,假設 HAM-CYCLE =
所以此題為
- yee
Show that the Hamiltonian-path problem can be solved in polynomial time on directed acyclic graphs. Give an efficient algorithm for the problem.
【解題思路】
題目要在DAG中找到Hamiltonian-path,將topological sort 中While迴圈的條件改成若Q不等於1就停止,代表有超過兩個點的in degree等於0,所以找不到Hamiltonian-path。
【蘇都扣】
【時間複雜度】
- Mark
Consider the language GRAPH-ISOMORPHISM = {<𝐺1, 𝐺2> : 𝐺1 and 𝐺2 are isomorphic graph}. Prove that GRAPH-ISOMORPHISM ∊ NP by describing a polynomial-time algorithm to verify the language.
映射函數 f題目提供的,根據助教課的解釋,我們假設已有映射函數的情況下找出Polynomial-Time的解法驗證兩個G是否為同構。
蘇都扣
Time Complexity
對每個V檢查各自的邊,透過假設的映射函數find()檢查兩圖是否同構
- songchiu
Consider the problem of finding the longest simple cycle in an undirected graph.
Give a related decision problem.Show the decision problem is an NP problem.
先說明一下 decision problem
的意思是可否找到答案,yes or no ()
假設有一圖,我們要在裡面找到一條,稱之為,其點依序為
為確保該是否為,從開始走,檢查是否在裡。最後檢查完後如果都在裡,就回傳;反之則回傳
(註:每個點只會被走過一次)
由於每個點只會被走訪一次
因此我們可以推論出
參考連結:certificate