1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) 0 1 3 5 4 2 (b) 0 1 2 4 3 5 (c) 0 1 4 3 1 2 (d) 0 2 3 5 4 1 (e) 0 1 3 5 6.

Slides:



Advertisements
Similar presentations
Complexity Classes: P and NP
Advertisements

What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
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 
Umans Complexity Theory Lectures Lecture 2a: Reductions & Completeness.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems.
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
Computational Complexity CSC 172 SPRING 2002 LECTURE 27.
NP-complete and NP-hard problems
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
CSCE350 Algorithms and Data Structure
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.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
1 1. Draw the machine schema for a TM which when started with input 001 halts with abbb on the tape in our standard input format. 2. Suppose you have an.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
1 3-COLOURING: Input: Graph G Question: Does there exist a way to 3-colour the vertices of G so that adjacent vertices are different colours? 1.What could.
CSC 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.
CSCI 2670 Introduction to Theory of Computing December 1, 2004.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
Complexity 25-1 Complexity Andrei Bulatov Counting Problems.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
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.
NP-Complete Problems Algorithm : Design & Analysis [23]
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.
1 Suppose I construct a TM M f which: 1. Preserves its input u. 2. Simulates a machine M b on input ε. 3. If M b hangs on input ε, force an infinite loop.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 30, 2014.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
CSC 413/513: Intro to Algorithms
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.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
1 Create a NDFA which accepts the language generated by this context-free grammar. Start symbol: S S → aa S S → ε S → M M → bbb M → ab M M → b S M → E.
Given this 3-SAT problem: (x1 or x2 or x3) AND (¬x1 or ¬x2 or ¬x2) AND (¬x3 or ¬x1 or x2) 1. Draw the graph that you would use if you want to solve this.
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.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
Young CS 530 Ad. Algo. D&A NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey.
The NP class. NP-completeness
NP-Completeness NP-Completeness Graphs 5/7/ :49 PM x x x x x x x
Richard Anderson Lectures NP-Completeness
Hard Problems Introduction to NP
Intro to Theory of Computation
Richard Anderson Lecture 25 NP-Completeness
How Hard Can It Be?.
NP-Completeness NP-Completeness Graphs 12/3/2018 2:46 AM x x x x x x x
1. for (i=0; i < n; i+=2) if (A[i] > A[i+1]) swap(A[i], A[i+1])
NP-Complete Problems.
Richard Anderson Lecture 27 NP Completeness
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
Prove this problem is in NP
CSE 589 Applied Algorithms Spring 1999
Richard Anderson Lecture 25 NP Completeness
Presentation transcript:

1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e) Give pseudocode for an algorithm to check if a seqence S[0..(n-1)] for a graph G stored in an adjacency matrix A[0..(n-1)][0..(n-1)] gives a Hamilton cycle.

2 Assignment #5: Available from class web page. Due Friday Dec. 2 at the beginning of class. Final exam tutorial: Sunday Dec. 4 at 12:00pm

3 Introduction to NP-completeness. The class of NP-complete problems is defined. Satisfiability, the most famous NP-complete problem is introduced. To prove new problems are undecidable, we use halting problem reductions. To prove new problems are NP-complete, reductions are also used but the transformation must preserve polynomial running time complexity.

4 Table 1: Comparing polynomial and exponential time complexity. Assume a problem of size one takes seconds (1 microsecond). Size n n second second second second second second n2n second second second second second second n3n second0.008 second0.027 second0.064 second0.125 second0.216 second n5n5 0.1 second3.2 second24.3 second1.7 minutes5.2 minutes13.2 minutes 2n2n second1.0 second17.9 minutes12.7 days35.7 years366 centuries 3n3n second58 minutes6.5 years3855 centuries2*10 8 centuries 1.3*10 13 centuries (from M. R. Garey and D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP-completeness, W. H. Freeman, New York, 1979.)

5 Time Complexity function With present computer With computer 100 times faster With computer 1000 times faster nN1100 N11000 N1 n2n2 N210 N231.6 N2 n3n3 N34.46 N310 N3 n5n5 N42.5 N43.98 N4 2n2n N5N5+6.64N n3n N6N6+4.19N Table 2: Effect of improved technology on several polynomial and exponential time algorithms. The following table represents the size of the largest problem instance solvable in 1 hour. (from M. R. Garey and D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP-completeness, W. H. Freeman, New York, 1979.)

6 Class P A decision problem (yes/no question) is in the class P if there is a polynomial time algorithm for solving it. Polynomial time: O(n c ) for some constant c. If a problem is solvable in polynomial time for some sensible encoding of the input some reasonable machine (TM/RAM/PC) it can be solved in polynomial time for all other sensible encodings/reasonable machines.

7 A program that runs on a Random Access Machine (such as our modern day computers) in time T(n) can be simulated on a single tape Turing machine in time O(T 3 (n)). This distinction is made between polynomial time and anything else (sometimes referred to as exponential time) because of the blowup in computation times which appear for exponential algorithms.

8 Example problem which is in P: Minimum Weight Spanning Tree (CSC 225). Input: Graph G, integer k. Question: Does G have a spanning tree of weight at most k? If you are provided with a tree with weight at most k as part of the solution, the answer can be verified in O(n 2 ) time.

9 Class NP A decision problem (yes/no question) is in the class NP if it has a nondeterministic polynomial time algorithm. Informally, such an algorithm: 1.Guesses a solution (nondeterministically). 2. Checks deterministically in polynomial time that the answer is correct. Or equivalently, when the answer is "yes", there is a certificate (a solution meeting the criteria) that can be verified in polynomial time (deterministically).

10 Does G have a Ham. cycle? Certificate: 0, 1, 2, 11, 10, 9, 8, 7, 6, 5, 14, 15, 16, 17, 18, 19, 12, 13, 3, 4 Hamilton Cycle is in NP: Input graph G.

11 Independent Set is in NP: Given a graph G and integer k, does G have an independent set of order k? Certificate, k=3: 2, 3, 8 Vertices u and v are independent if edge (u, v) is not in G.

12 Matching is in NP: Given a graph G and integer k, does G have a k-edge matching? Certificate, k=5: (a,f) (b,g) (c,h) (d,i)(e,j) Matching: disjoint edges.

13 Does P= NP? the Clay Mathematics Institute has offered a $1 million US prize for the first correct proof. Some problems in NP not known to be in P: Hamilton Path/Cycle Independent Set Satisfiability Note: Matching is in P. Learn more in a graph algorithms class.

14 NP-completeness I can't find an efficient algorithm, I guess I'm just too dumb.

15 I can't find an efficient algorithm, because no such algorithm is possible.

16 I can't find an efficient algorithm, but neither can all these famous people.

17 NP-complete Problems The class of problems in NP which are the "hardest" are called the NP-complete problems. A problem Q in NP is NP-complete if the existence of a polynomial time algorithm for Q implies the existence of a polynomial time algorithm for all problems in NP. Steve Cook in 1971 proved that SAT is NP- complete. Proof: will be given in our last class. Other problems: use reductions.

18 Bible for NP- completeness: M. R. Garey and D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP- Completness, W. H. Freeman, 1st ed. (1979).

19 A problem Q in NP is NP-complete if the existence of a polynomial time algorithm for Q implies the existence of a polynomial time algorithm for all problems in NP.

20 SAT (Satisfiability) Variables: u 1, u 2, u 3,... u k. A literal is a variable u i or the negation of a variable ¬ u i. If u is set to true then ¬ u is false and if u is set to false then ¬ u is true. A clause is a set of literals. A clause is true if at least one of the literals in the clause is true. The input to SAT is a collection of clauses.

21 This SAT problem has solution u 1 =T, u 2 =F, u 3 = T, u 4 =F (u 1 OR u 2 OR u 4 ) AND (¬ u 2 OR u 4 ) AND (¬ u 1 OR u 3 ) AND (¬ u 4 OR ¬ u 1 ) Does this SAT problem have a solution? ( u 1 OR u 2 ) AND (¬ u 2 OR u 3 ) AND (¬ u 3 OR ¬ u 1 ) AND (¬ u 2 OR ¬ u 3 ) AND ( u 3 OR ¬ u 1 ) [

22 SAT (Satisfiability) The output is the answer to: Is there an assignment of true/false to the variables so that every clause is satisfied (satisfied means the clause is true)? If the answer is yes, such an assignment of the variables is called a truth assignment. SAT is in NP: Certificate is true/false value for each variable in satisfying assignment.

23