计算模型与算法技术:11-Limitations of Algorithm Power_第1页
计算模型与算法技术:11-Limitations of Algorithm Power_第2页
计算模型与算法技术:11-Limitations of Algorithm Power_第3页
计算模型与算法技术:11-Limitations of Algorithm Power_第4页
计算模型与算法技术:11-Limitations of Algorithm Power_第5页
已阅读5页,还剩24页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Chapter 11 Copyright 2007 Pearson Addison-Wesley. All rights reserved.Limitations of Algorithm PowerLimitations of Algorithm PowerIntellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless.-Max Born

2、 (18821970), My Life and My Views, 1968Limitations of Algorithm PowerA fair assessment of algorithms asproblem-solving tools is inescapable:they are very powerful instruments, especially when they are executed by modern computers.But the power of algorithms is not unlimited34411.1 Lower-Bound Argume

3、ntsTrivial Lower BoundsTrivial Lower Bounds The simplest method of obtaining a lower-bound class is based on counting the number of items in the problems input that must be processed and the number of output items that need to be produced. Since any algorithm must at least “read” all the items it ne

4、eds to process and “write” all its outputs, such a count yields a trivial lower bound.Example: any algorithm for generating all permutations of n distinct items must be in (n!) because the size of the output is n!.Information-Theoretic ArgumentsInformation-Theoretic Seeks to establish a lower bound

5、based on the amount of information it has to produce.Example: The well-known game of deducing a positive integer between 1 and n selected by somebody by asking that person questions with yes/no answers. The amount of uncertainty that any algorithm solving this problem has to resolve can be measured

6、by log2n.Adversary ArgumentsAdversary Arguments It is based on following the logic of a malevolent but honest adversary: the malevolence makes him push the algorithm down the most time-consuming path, and his honesty forces him to stay consistent with the choices already made. A lower bound is then

7、obtained by measuring the amount of work needed to shrink a set of potential inputs to a single input along the most time-consuming path.Example: consider the problem of merging two sorted lists of size n into a single sorted list of size 2n. a1 a2 . . . an and b1 b2 . . . bn2n 1 is, indeed, a lower

8、 bound !Problem Reduction8TABLE 11.1 Problems often used for establishing lower bounds by problem reductionshow that the problems of computing the product of two n-digit integers andsquaring an n-digit integer belong to the same complexity class, despite the latterbeing seemingly simpler than the fo

9、rmer.For example:9911.2 Decision TreesExamples of Decision TreesSpecifically, it is not difficult to prove that for any binary tree with l leaves and height h,Decision Trees for SortingDecision Trees for SortingInequality (11.1) implies that the height of a binary decision tree for anycomparison-bas

10、ed sorting algorithm and hence the worst-case number of comparisons made by such an algorithm cannot be less than :Using Stirlings formula for n!, we getDecision Trees for SortingUnder the standard assumption that all n! outcomes of sorting are equallylikely, the following lower bound on the average

11、 number of comparisons Cavgmade by any comparison-based algorithm in sorting an n-element list has beenproved:Decision Trees for Searching a Sorted ArrayDecision Trees for Searching a Sorted Array161611.3 P, NP, and NP-Complete ProblemsP, NP, and NP-Complete ProblemsDEFINITION 1 We say that an algor

12、ithm solves a problem in polynomial time if its worst-case time efficiency belongs to O(p(n) where p(n) is a polynomial of the problems input size n. (Note that since we are using big-oh notation here, problems solvable in, say, logarithmic time are solvable in polynomial time as well.) Problems tha

13、t can be solved in polynomial time are called tractable, andproblems that cannot be solved in polynomial time are called intractable.P and NP ProblemsInformally, we can think about problems that can be solved in polynomial time as the set that computer science theoreticians call P. A more formal def

14、inition includes in P only decision problems, which are problems with yes/no answers.DEFINITION 2 Class P is a class of decision problems that can be solved inpolynomial time by (deterministic) algorithms. This class of problems is calledpolynomial.undecidable problem :some decision problems cannot

15、be solved at all by any algorithm.P and NP Problemshalting problem: given a computer program and an input to it, determine whether the program will halt on that input or continue working indefinitely on it.Hamiltonian circuit problem :Determine whether a given graph has aHamiltonian circuita path th

16、at starts and ends at the same vertex and passesthrough all the other vertices exactly once.Knapsack problem: Find the most valuable subset of n items of given positiveinteger weights and values that fit into a knapsack of a given positive integercapacity.Traveling salesman problem :Find the shortes

17、t tour through n cities withknown positive integer distances between them (find the shortest Hamiltonian circuit in a complete graph with positive integer weights).P and NP ProblemsPartition problem: Given n positive integers, determine whether it is possibleto partition them into two disjoint subse

18、ts with the same sum.Bin-packing problem: Given n items whose sizes are positive rational numbers not larger than 1, put them into the smallest number of bins of size 1.Graph-coloring problem :For a given graph, find its chromatic number,which is the smallest number of colors that need to be assigne

19、d to the graphsvertices so that no two adjacent vertices are assigned the same color.Integer linear programming problem :Find the maximum (or minimum)value of a linear function of several integer-valued variables subject to a finiteset of constraints in the form of linear equalities and inequalities

20、.P and NP ProblemsDEFINITION 3 A nondeterministic algorithm is a two-stage procedure that takes as its input an instance I of a decision problem and does the following.Nondeterministic (“guessing”) stage: An arbitrary string S is generated that can be thought of as a candidate solution to the given

21、instance I (but may be complete gibberish as well).Deterministic (“verification”) stage: A deterministic algorithm takes both I and S as its input and outputs yes if S represents a solution to instance I. (If S is not a solution to instance I , the algorithm either returns no or is allowed not to ha

22、lt at all.)DEFINITION 4 Class NP is the class of decision problems that can be solved bynondeterministic polynomial algorithms. This class of problems is called nondeterministic polynomial.P NP.But P=NP?NP-Complete ProblemsInformally, an NP-complete problem is a problem in NP that is as difficult as

23、 anyother problem in this class because, by definition, any other problem in NP canbe reduced to it in polynomial time (shown symbolically in Figure 11.6).NP-Complete ProblemsDEFINITION 5 A decision problem D1 is said to be polynomially reducible toa decision problem D2, if there exists a function t

24、 that transforms instances of D1to instances of D2 such that:1. t maps all yes instances of D1 to yes instances of D2 and all no instances of D1to no instances of D2.2. t is computable by a polynomial time algorithm.DEFINITION 6 A decision problem D is said to be NP-complete if:1. it belongs to class NP2. every problem in NP is polynomially reducible to DNP-Complete ProblemsShowing that a decision problem is NP-complete can be done in two steps.First, one needs to show that the problem in question is in NP.The second step is to show that every problem in NP is reducible to the prob

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论