计算机问题求解笔记
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
NP P ⊆}
,...,,{21l x x x S =},...,3,2,1{l A ⊆∑∑∈∉=A i A
i i i x x },...,,{21l
x
x x S =},...,2,1{l A ⊆∑∈=A
i i t
x The nature of computation
第四章
NP 的informal 定义
A decision problem is in NP if whenever the answer for a particular instance is “yes”,there is a simple proof of this fact.(simple proof means that we can check in polynomial time).
NP P ⊆
If a problem is in P ,it has a polynomial algorithm that is guaranteed to give the right answer.If the input is a yes-instance,the sequence of steps executed by this algorithm,which end with it returning “yes”,constitutes a proof of that fact.thus .
So,P is a set of decision problem solvable in polynomial time.
GRAPH k-COLORING
Input: a graph G
Question : is there a proper k-coloring of G?
Reduction
A is reducible to
B and write B A ≤,if there is a polynomial-time algorithm that translates
instances of A to instances of B.in that case,B is at least as hard as A.
Graph 3-coloring ≤planar graph 3-coloring
只有当k=3时,才可以这么做,当k>3时,graph k-coloring 不能规约到planar graph k-coloring. 对于平面图而言,增加染色数,图的可染色问题会变得简单。但是对于一般的图来说,增加染色数不会降低问题的难度。
Exercise :prove that Graph k-coloring ≤graph(k+1)-coloring for any k .
Hint :add a vertex connected to all other k vertexes.
CNF:Conjunctive normal form
CNF is the AND of a series of clauses and each clause is the OR of a set of literals,where a literal is either a variable or its negation.
SAT(约束可满足问题)
Input: A CNF Boolean formula Question: is ϕ satisfiable?
Graph 3-coloring ≤ SAT
K-SAT
Input : A CNF Boolean formula ϕ ,where each clause contains k variables
Question:is ϕ satisfiable?
Integer Partitioning
Input : A list of positive integers Question : is there a balanced partition,i.e,a subset s.t. Subset sum
Input : A set of positive integers and an integer t Question : Does there exist a subset such that Independent Set Formally,given a graph G = (V,E),we say that a subset is independent if no two vertices in S are adjacent.
Input: A graph G and an integer k
Question: Does G have an independent set of size k or more?
Vertex Cover
)
,...,,(21n x x x φ
A subset is a vertex cover if for every edge,at least one of e’s endpoint is in S
Input: A graph G and an integer k
Question: Does G have a vertex cover of size k or less?
Clique(最大完全子图)
Input: A graph G and an integer k
Question: Does G have a clique of size k or more?
三者可以相互规约,S为独立集,则所有边集中每条边至少有一个端点在G-S中;从而,最大的独立集对应最小的点覆盖G-S;clique的补图P,即,反之亦然,则clique中的最大完全子图对应于补图P中的最大独立集。
Formal definition of NP
NP is the class of problems A of the following form:
X is a yes-instance of A if and only if there exists a such that is a yes-instance of B where B is a decision problem in P regarding pairs and where .
EXP = TIME()
NTIME(f(n)) is the class of problems A of the following form:
is a yes-instance of A if and only if there exists a such that is a yes-instance of B.where B is a decision problem in TIME(f(n)) regarding pairs and where.For instance,NEXP = NTIME().
More general,we have:
Another definition of NP:
NP is the class of properties A of the form:
Where B is in P and where .
Co-NP的定义
No Hamiltonian path
Input: A graph G
Question: is it true that G has no hamiltonian path?
This is a very different problem.there is a simple proof if the answer is “no”,but it seems hard to prove that the answer is “yes” without an exhausive search.problems like this have a complexity class of their own,called CoNP,the class of problems in which,if the input is a no-instance,there is a simple proof of that fact.
Primality
Input: A n-bit integer
Question: Is prime
记表示和模运算相等。
Suppose is a prime,if is an integer greater than 1 and less than ,its order is the smallest such that.
Fermat’s little theorem states that if is prime,then for any . this does not mean that the order of is .however,it does imply that is a divisor of .
Lehmer’s theorem
is prime if and only if an exists with order exactly .such an is called a primitive root.
验证是否为素数,只需要找出一个,满足的order是.
要证明的order为,要验证.这个问题可以简化为
,因为:
假设的order为,
,因为为整数