A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 CSC 421: Algorithm Design & Analysis Spring 2013 Complexity & Computability  lower bounds on problems brute force, decision trees, adversary arguments,
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
CSCE350 Algorithms and Data Structure
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
P and NP. Computational Complexity Recall from our sorting examples at the start of class that we could prove that any sort would have to do at least.
P and NP.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
CSE 3813 Introduction to Formal Languages and Automata Chapter 14 An Introduction to Computational Complexity These class notes are based on material from.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
LIMITATIONS OF ALGORITHM POWER
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
1 CSC 421: Algorithm Design & Analysis Spring 2014 Complexity & lower bounds  brute force  decision trees  adversary arguments  problem reduction.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
Chapter 10 NP-Complete Problems.
Hard Problems Introduction to NP
NP-Completeness Yin Tat Lee
Lower Bound Theory.
Analysis and design of algorithm
ICS 353: Design and Analysis of Algorithms
Chapter 11 Limitations of Algorithm Power
CSC 380: Design and Analysis of Algorithms
P, NP and NP-Complete Problems
The Theory of NP-Completeness
P, NP and NP-Complete Problems
Our old list of problems
RAIK 283 Data Structures & Algorithms
Presentation transcript:

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the largest element in a set of n numbers b number of comparisons needed to sort an array of size n b number of comparisons necessary for searching in a sorted array b number of multiplications needed to multiply two n-by-n matrices

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 2 Lower Bounds (cont.) b Lower bound can be an exact countan exact count an efficiency class (  )an efficiency class (  ) b Tight lower bound: there exists an algorithm with the same efficiency as the lower bound Problem Lower boundTightness Problem Lower boundTightness sorting  (nlog n) yes sorting  (nlog n) yes searching in a sorted array  (log n) yes searching in a sorted array  (log n) yes element uniqueness  (nlog n) yes element uniqueness  (nlog n) yes n-digit integer multiplication  (n) unknown n-digit integer multiplication  (n) unknown multiplication of n-by-n matrices  (n 2 ) unknown multiplication of n-by-n matrices  (n 2 ) unknown

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 3 Methods for Establishing Lower Bounds b trivial lower bounds b information-theoretic arguments (decision trees) b adversary arguments (SKIP) b problem reduction

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 4 Trivial Lower Bounds Trivial lower bounds: based on counting the number of items that must be processed in input and generated as output Examples b finding max element b polynomial evaluation b sorting b element uniqueness b Hamiltonian circuit existence Conclusions b may and may not be useful b be careful in deciding how many elements must be processed (min-max)

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 5 Decision Trees Decision tree —model algorithms that use comparisons: b internal nodes represent comparisons b leaves represent outcomes b How many orderings of 2 elements? Of 3? Of n? b Tree for 3-element insertion sort [insert b in a, then c into ab]

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 6 Decision Trees and Sorting Algorithms b Any comparison-based sorting algorithm can be represented by a decision tree b Number of leaves (outcomes)  n! b Height of binary tree with n! leaves   log 2 n!  b Minimum number of comparisons in the worst case   log 2 n!  for any comparison-based sorting algorithm b  log 2 3!  =  log 2 6  = 3 b  log 2 n!   n log 2 n, for large n b This lower bound is tight (mergesort)

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 7 Adversary Arguments (SKIP) Adversary argument: a method of proving a lower bound by playing role of adversary that makes algorithm work the hardest by adjusting input Example 1: “Guessing” a number between 1 and n with yes/no questions questions Adversary: Puts the number in a larger of the two subsets generated by last question Example 2: Merging two sorted lists of size n a 1 < a 2 < … < a n and b 1 < b 2 < … < b n a 1 < a 2 < … < a n and b 1 < b 2 < … < b n Adversary: a i < b j iff i < j Output b 1 < a 1 < b 2 < a 2 < … < b n < a n requires 2n-1 comparisons of adjacent elements

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 8 Lower Bounds by Problem Reduction If we know a LB for alg A, can we use that knowledge to find a LB for alg B? Remember reduction: - Minheap reduces to maxheap - Minheap reduces to maxheap - Minimum reduces to sort - Minimum reduces to sort - Element uniqueness for pairs reduces to closest pair - Element uniqueness for pairs reduces to closest pair Which would be most useful? A [  (f )] reduces to B [  (? )] A [  (f )] reduces to B [  (? )] B [  (? )] reduces to A [  (f )] B [  (? )] reduces to A [  (f )] [Assume the reduction itself is fast (ie O(f)) ]

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 9 Lower Bounds by Problem Reduction Which would be most useful? A [  (f )] reduces to B [  (? )] A [  (f )] reduces to B [  (? )] B [  (? )] reduces to A [  (f )] B [  (? )] reduces to A [  (f )] Proc A [  (f )] Proc B [  (? )] … … … … B [  (? )] A [  (f )] B [  (? )] A [  (f )] … … … … A= [  (? )] => ??? A = [  (? )] => ???

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 10 Lower Bounds by Problem Reduction Which would be most useful? A [  (f )] reduces to B [  (? )] A [  (f )] reduces to B [  (? )] B [  (? )] reduces to A [  (f )] B [  (? )] reduces to A [  (f )] Proc A [  (f )] Proc B [  (? )] … … … … B [  (? )] A [  (f )] B [  (? )] A [  (f )] … … … … A= [  (f )] => B = [  (f )] A = [  (f )] => Nothing

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 11 Lower Bounds by Problem Reduction To show lower bounds: Reduce problem with known lower bound to problem with unknown lower bound. Idea: If problem P is at least as hard as problem Q, then a lower bound for Q is also a lower bound for P. bound for Q is also a lower bound for P. Hence, find problem Q with a known lower bound that can be reduced to problem P in question. Hence, find problem Q with a known lower bound that can be reduced to problem P in question. Example: P is finding MST for n points in Cartesian plane Q is element uniqueness problem (known to be in  (nlogn))

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 12 Lower Bounds by Problem Reduction Example: P is finding MST for n points in Cartesian plane Q is element uniqueness problem (known to be in  (nlogn)) Reduce Element Uniqueness to MST: Unique (S : IntSet = {x1, x2, …, xn}) [Known  (nlogn)] Unique (S : IntSet = {x1, x2, …, xn}) [Known  (nlogn)] P : PairSet = {(x1, 0), (x2, 0), …, (xn, 0)} P : PairSet = {(x1, 0), (x2, 0), …, (xn, 0)} T : Tree = MST (P) T : Tree = MST (P) D : Nat = min_length (edges of T) D : Nat = min_length (edges of T) return D = 0 return D = 0 Thus, MST is  (nlogn)! Thus, MST is  (nlogn)!

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 13 P, NP, NP Complete Example: - Classifying Problems - Classifying Problems - Tractable and non-tractable - Optimization and Decision Problems - Problem Classes - Problem Classes - P - NP - NP - NP Complete - NP Complete

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 14 Classifying Problem Complexity Is the problem tractable, i.e., is there a polynomial-time (O(p(n)) algorithm that solves it? Possible answers: b yes (give examples) b no because it’s been proved that no algorithm exists at all (e.g., Turing’s halting problem)because it’s been proved that no algorithm exists at all (e.g., Turing’s halting problem) because it’s been be proved that any algorithm takes exponential timebecause it’s been be proved that any algorithm takes exponential time b unknown

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 15 Problem Types: Optimization and Decision b Optimization problem: find a solution that maximizes or minimizes some objective function b Decision problem: answer yes/no to a question Many problems have decision and optimization versions. E.g.: traveling salesman problem b optimization: find Hamiltonian cycle of minimum length b decision: find Hamiltonian cycle of length  m Decision problems are more convenient for formal investigation of their complexity.

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 16 Class P P: the class of decision problems that are solvable in O(p(n)) time, where p(n) is a polynomial of problem’s input size n Examples: b searching b element uniqueness b graph connectivity b graph acyclicity b primality testing (finally proved in 2002)

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 17 Class NP NP (nondeterministic polynomial): class of decision problems whose proposed solutions can be verified in polynomial time = solvable by a nondeterministic polynomial algorithm A nondeterministic polynomial algorithm is an abstract two-stage procedure that: b generates a random string purported to solve the problem b checks whether this solution is correct in polynomial time By definition, it solves the problem if it’s capable of generating and verifying a solution on one of its tries Why this definition? b led to development of the rich theory called “computational complexity”

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 18 Example: CNF satisfiability Problem: Is a boolean expression in its conjunctive normal form (CNF) satisfiable, i.e., are there values of its variables that makes it true? This problem is in NP. Nondeterministic algorithm: b Guess truth assignment b Substitute the values into the CNF formula to see if it evaluates to true Example: ( A | ¬B | ¬C ) & ( A | B ) & ( ¬B | ¬D | E ) & ( ¬D | ¬E ) Truth assignments: A B C D E Checking phase: O(n)

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 19 What problems are in NP? b Hamiltonian circuit existence b Partition problem: Is it possible to partition a set of n integers into two disjoint subsets with the same sum? b Decision versions of TSP, knapsack problem, graph coloring, and many other combinatorial optimization problems. (Few exceptions include: MST, shortest paths) b All the problems in P can also be solved in this manner (no guessing is necessary), so we have: P  NP P  NP  Big question: Is P = NP ? Or is P ⊂ NP ? Answer unknown. Current approach: focus on hardest NP problemsAnswer unknown. Current approach: focus on hardest NP problems

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 20 NP-Complete : The Hardest NP Problems A decision problem D in NP is NP-complete if it’s as hard as (ie no easier than) any and every problem in NP. That is: b D is in NP b every problem in NP is polynomial-time reducible to D Think: Which problems can be easier?

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 21 Cook: The First NP-Complete Problem A decision problem D that is in NP is NP-complete if b D is in NP b Every problem in NP is polynomial-time reducible to D How to prove every NP problem is reducible to D? Not easy! Cook’s theorem (1971): CNF-sat is NP-complete

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 22 Proving Other Problems are NP-Complete Prove other problems are NP-complete by polynomial- time reductions from a known NP-complete problem Pay attention to the direction of the reductions Examples: TSP, knapsack, partition, graph-coloring and hundreds of other problems of combinatorial nature

A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 23 P = NP ? Dilemma Revisited b If P = NP then every problem in NP (including all NP- complete problems) could be solved in polynomial time b If a polynomial-time algorithm for just one NP-complete problem is discovered, then every problem in NP can be solved in polynomial time, i.e., P = NP b Most but not all researchers believe that P  NP, i.e. P is a proper subset of NP