Download presentation

Presentation is loading. Please wait.

1
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.

2
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-1 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality testing b Traveling salesman problem b Knapsack problem b Chess b Towers of Hanoi b Program termination

3
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-2 Classifying a problem’s complexity Is there a polynomial-time algorithm that solves the problem? Possible answers: b yes b no because it can be proved that all algorithms take exponential timebecause it can be proved that all algorithms take exponential time because it can be proved that no algorithm exists at all to solve this problembecause it can be proved that no algorithm exists at all to solve this problem b don’t know b don’t know, but if such algorithm were to be found, then it would provide a means of solving many other problems in polynomial time

4
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-3 Types of problems b Optimization problem: construct a solution that maximizes or minimizes some objective function b Decision problem: answer yes/no to a question Many problems will have decision and optimization versions. Eg: Traveling salesman problem b optimization: find hamiltonian cycle of minimum weight b decision: find hamiltonian cycle of weight < k

5
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-4 Some more problems b Partition: Given n positive integers, determine whether it is possible to partition them into two disjoint subsets with the same sum b Bin packing: given n items whose sizes are positive rational numbers not larger than 1, put them into the smallest number of bins of size 1 b Graph coloring: For a given graph find its chromatic number, ie, the smallest number of colors that need to be assigned to the graph’s vertices so that no two adjacent vertices are assigned the same color b CNF satisfiability: Given a boolean expression in conjunctive normal form (conjunction of disjunctions of literals), is there a truth assignment to the variables that makes the expression true?

6
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-5 The class P P: the class of decision problems that are solvable in O(p(n)), where p(n) is a polynomial on n Why polynomial? b if not, very inefficient b nice closure properties b machine independent in a strong sense

7
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-6 The class NP NP: the class of decision problems that are solvable in polynomial time on a nondeterministic machine b (A determinstic computer is what we know) b A nondeterministic computer is one that can “guess” the right answer or solution b Thus NP can also be thought of as the class of problems whose solutions can be verified in polynomial time; orwhose solutions can be verified in polynomial time; or that can be solved in polynomial time on a machine that can pursue infinitely many paths of the computation in parallelthat can be solved in polynomial time on a machine that can pursue infinitely many paths of the computation in parallel b Note that NP stands for “Nondeterministic Polynomial- time”

8
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-7 Example: CNF satisfiability b This problem is in NP. Nondeterministic algorithm: Guess truth assignmentGuess truth assignment Check assignment to see if it satisfies CNF formulaCheck assignment to see if it satisfies CNF formula b Example: (A⋁¬B ⋁ ¬C ) ⋀ (¬A ⋁ B) ⋀ (¬ B ⋁ D ⋁ F ) ⋀ (F ⋁ ¬ D) b Truth assignments: A B C D E F A B C D E F 1. 0 1 1 0 1 0 2. 1 0 0 0 0 1 3. 1 1 0 0 0 1 4.... (how many more?) Checking phase: Θ (n)

9
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-8 Where are we now? b Exhibited nondeterministic poly-time algorithm for CNF- satisfiability b CNF-sat is in NP b Similar algorithms can be found for TPS, HC, Partition, etc proving that these problems are also in NP b All the problems in P can also be solved in this manner (but no guessing is necessary), so we have: P ⊆ NP b Big question: P = NP ?

10
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-9 NP-complete problems b A decision problem D is NP-complete iff 1.D ∈ NP 2.every problem in NP is polynomial-time reducible to D b Cook’s theorem (1971): CNF-sat is NP-complete b Other NP-complete problems obtained through polynomial-time reductions of known NP-complete problems b The class of NP-complete problems is denoted NPC

11
Copyright © 2007 Pearson Addison-Wesley. All rights reserved Design and Analysis of Algorithms - Chapter 1011-10 Reductions b Example: Polynomial-time reduction of directed HC to undirected HC y v u x y3y3 v3v3 What does this prove? HC is harder or easier for directed graphs? HC is harder or easier for directed graphs? if HC is NPC for directed graphs, is it also NPC for undirected graphs? if HC is NPC for directed graphs, is it also NPC for undirected graphs? OR OR if HC is NPC for undirected graphs, is it also NPC for directed graphs? if HC is NPC for undirected graphs, is it also NPC for directed graphs? → x3x3 x2x2 x1x1 y1y1 y2y2 u1u1 u2u2 u3u3 v2v2 v1v1

Similar presentations

© 2021 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google