算法设计与分析算法设计与分析 (1).pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《算法设计与分析算法设计与分析 (1).pdf》由会员分享,可在线阅读,更多相关《算法设计与分析算法设计与分析 (1).pdf(35页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1Chapter 8NP and ComputationalIntractabilitySlides by Kevin Wayne.Copyright 2005 Pearson-Addison Wesley.All rights reserved.8.3 Definition of NP3Decision ProblemsDecision problem.X is a set of strings.Instance:string s.Algorithm A solves problem X:A(s)=yesiff s X.Polynomial time.Algorithm A runs in
2、poly-time if for every string s,A(s)terminates in at most p(|s|)steps,where p()is some polynomial.PRIMES:X=2,3,5,7,11,13,17,23,29,31,37,.Algorithm.Agrawal-Kayal-Saxena,2002 p(|s|)=|s|8.4Definition of PP.Decision problems for which there is a poly-time algorithm.ProblemDescriptionAlgorithmYesNoMULTIP
3、LEIs x a multiple of y?Grade school division51,1751,16RELPRIMEAre x and y relatively prime?Euclid(300 BCE)34,3934,51PRIMESIs x prime?AKS(2002)5351EDIT-DISTANCEIs the edit distance between x and y less than 5?Dynamic programmingniether neitheracgggt tttttaLSOLVEIs there a vector x that satisfies Ax=b
4、?Gauss-Edmonds elimination0112420315,4236100111011,1115NPCertification algorithm intuition.Certifier doesnt determine whether s X on its own;rather,it checks a proposed proof t that s X.Def.Algorithm C(s,t)is a certifier for problem X if for every string s,s X iff there exists a string t such that C
5、(s,t)=yes.NP.Decision problems for which there exists a poly-time certifier.Remark.NP stands for nondeterministic polynomial-time.C(s,t)is a poly-time algorithm and|t|p(|s|)for some polynomial p().6Certifiers and Certificates:CompositeCOMPOSITES.Given an integer s,is s composite?Certificate.A nontri
6、vial factor t of s.Note that such a certificate exists iff s is composite.Moreover|t|s|.Certifier.Instance.s=437,669.Certificate.t=541 or 809.Conclusion.COMPOSITESis in NP.437,669=541 809boolean C(s,t)if(t 1 or t s)return falseelse if(s is a multiple of t)return trueelse return false7Certifiers and
7、Certificates:3-SatisfiabilitySAT.Given a CNF formula,is there a satisfying assignment?Certificate.An assignment of truth values to the n boolean variables.Certifier.Check that each clause in has at least one true literal.Ex.Conclusion.SATis in NP.x1 x2 x3x1 x2 x3x1 x2 x4 x1 x3 x4x11,x21,x3 0,x41inst
8、ance scertificate t8Certifiers and Certificates:Hamiltonian CycleHAM-CYCLE.Given an undirected graph G=(V,E),does there exist a simple cycle C that visits every node?Certificate.A permutation of the n nodes.Certifier.Check that the permutation contains each node in V exactly once,and that there is a
9、n edge between each pair of adjacent nodes in the permutation.Conclusion.HAM-CYCLEis in NP.instance scertificate t9P,NP,EXPP.Decision problems for which there is a poly-time algorithm.EXP.Decision problems for which there is an exponential-time algorithm.NP.Decision problems for which there is a pol
10、y-time certifier.Claim.P NP.Pf.Consider any problem X in P.By definition,there exists a poly-time algorithm A(s)that solves X.Certificate:t=,certifier C(s,t)=A(s).Claim.NP EXP.Pf.Consider any problem X in NP.By definition,there exists a poly-time certifier C(s,t)for X.To solve input s,run C(s,t)on a
11、ll strings t with|t|p(|s|).Return yes,if C(s,t)returns yesfor any of these.10The Main Question:P Versus NPDoes P=NP?Cook 1971,Edmonds,Levin,Yablonski,GdelIs the decision problem as easy as the certification problem?Clay$1 million prize.If yes:Efficient algorithms for 3-COLOR,TSP,FACTOR,SAT,If no:No
12、efficient algorithms possible for 3-COLOR,TSP,SAT,Consensus opinion on P=NP?Probably no.EXPNPPIf P NPIf P=NPEXPP=NPwould break RSA cryptography(and potentially collapse economy)8.4 NP-Completeness12Polynomial TransformationDef.Problem X polynomial reduces(Cook)to problem Y if arbitrary instances of
13、problem X can be solved using:Polynomial number of standard computational steps,plusPolynomial number of calls to oracle that solves problem Y.Def.Problem X polynomial transforms(Karp)to problem Y if given any input x to X,we can construct an input y such that x is a yesinstance of X iff y is a yesi
14、nstance of Y.Note.Polynomial transformation is polynomial reduction with just one call to oracle for Y,exactly at the end of the algorithm for X.Almost all previous reductions were of this form.Open question.Are these two concepts the same?we require|y|to be of size polynomial in|x|13NP-CompleteNP-c
15、omplete.A problem Y in NP with the property that for every problem X in NP,X pY.Theorem.Suppose Y is an NP-complete problem.Then Y is solvable in poly-time iff P=NP.Pf.If P=NP then Y can be solved in poly-time since Y is in NP.Pf.Suppose Y can be solved in poly-time.Let X be any problem in NP.Since
16、X pY,we can solve X inpoly-time.This implies NP P.We already know P NP.Thus P=NP.Fundamental question.Do there exist natural NP-complete problems?14The First NP-Complete ProblemTheorem.SAT(3-SAT)is NP-complete.Cook 1971,Levin 197315Establishing NP-CompletenessRecipe to establish NP-completeness of p
17、roblem Y.Step 1.Show that Y is in NP.Step 2.Choose an NP-complete problem X.Step 3.Prove that X pY.Justification.If X is an NP-complete problem,and Y is a problem in NP with the property that X PY then Y is NP-complete.Pf.Let W be any problem in NP.Then W P X P Y.By transitivity,W P Y.Hence Y is NP-
18、complete.16Some NP-Complete ProblemsSix basic genres of NP-complete problems and paradigmatic examples.Packing problems:INDEPENDENT SET.Covering problems:SET-COVER,VERTEX-COVER.Constraint satisfaction problems:SAT,3-SAT.Sequencing problems:HAMILTONIAN-CYCLE,TSP.Numerical problems:SUBSET-SUM,PARTITIO
19、N.Practice.Most NP problems are either known to be in P or NP-complete.Notable exceptions.Factoring,graph isomorphism,Nash equilibrium.Basic genres.Packing problems:INDEPENDENT SET.Covering problems:SET-COVER,VERTEX-COVER.Constraint satisfaction problems:SAT,3-SAT.Sequencing problems:HAMILTONIAN-CYC
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 算法设计与分析算法设计与分析 1 算法 设计 分析
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内