CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Lecture 21 NP-complete problems
Great Theoretical Ideas in Computer Science for Some.
CSE373: Data Structures & Algorithms Lecture 24: The P vs. NP question, NP-Completeness Nicki Dell Spring 2014 CSE 373 Algorithms and Data Structures 1.
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
Backtracking COP Backtracking  Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating.
Discrete Structures & Algorithms The P vs. NP Question EECE 320.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
Complexity Theory CSE 331 Section 2 James Daly. Reminders Project 4 is out Due Friday Dynamic programming project Homework 6 is out Due next week (on.
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 Graphs.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
NP-Completeness NP-Completeness Graphs 4/17/2017 4:10 AM x x x x x x x
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 22 Instructor: Paul Beame.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Complexity Theory: The P vs NP question Lecture 28 (Dec 4, 2007)
Programming & Data Structures
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,
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.
Great Theoretical Ideas in Computer Science.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
CSC 413/513: Intro to Algorithms NP Completeness.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
P vs NP: what is efficient computation? Great Theoretical Ideas In Computer Science Anupam GuptaCS Fall 2005 Lecture 29Dec 8, 2005Carnegie Mellon.
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.
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.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
COMPSCI 102 Introduction to Discrete Mathematics.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
COMPSCI 102 Introduction to Discrete Mathematics.
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.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
CSE373: Data Structure & Algorithms Lecture 21: More Sorting and Other Classes of Algorithms Lauren Milne Summer 2015.
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.
CS 146: Data Structures and Algorithms August 4 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 7 Time Complexity Some slides are in courtesy.
NPC.
Computational Complexity Shirley Moore CS4390/5390 Fall 2013 August 27, 2013.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
1 P and NP. 2 Introduction The Traveling Salesperson problem and thousands of other problems are equally hard in the sense that if we had an efficient.
CS 154 Formal Languages and Computability May 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
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.
Great Theoretical Ideas In Computer Science Anupam GuptaCS Fall 2006 Lecture 28Dec 7th, 2006Carnegie Mellon University Complexity Theory: the P.
Great Theoretical Ideas in Computer Science.
1 CSE 326: Data Structures: Graphs Lecture 23: Wednesday, March 5 th, 2003.
Conceptual Foundations © 2008 Pearson Education Australia Lecture slides for this course are based on teaching materials provided/referred by: (1) Statistics.
The NP class. NP-completeness
CSE373: Data Structure & Algorithms Lecture 23: More Sorting and Other Classes of Algorithms Catie Baker Spring 2015.
Great Theoretical Ideas in Computer Science
Lecture 22 Complexity and Reductions
Analysis and design of algorithm
P versus NP a Millennium Prize Problem
Chapter 11 Limitations of Algorithm Power
Great Theoretical Ideas In Computer Science
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
Lecture 22 Complexity and Reductions
Presentation transcript:

CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015

Admin Homework 6 is posted –Due next Wednesday –No partners

Algorithm Design Techniques Greedy – Shortest path, minimum spanning tree, … Divide and Conquer – Divide the problem into smaller subproblems, solve them, and combine into the overall solution – Often done recursively – Quick sort, merge sort are great examples Dynamic Programming – Brute force through all possible solutions, storing solutions to subproblems to avoid repeat computation Backtracking – A clever form of exhaustive search

Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating possibilities. A standard example of backtracking would be going through a maze. – At some point, you might have two options of which direction to go: Junction Portion A Portion B Backtracking: Idea

Junction Portion B Portion A One strategy would be to try going through Portion A of the maze. If you get stuck before you find your way out, then you "backtrack" to the junction. At this point in time you know that Portion A will NOT lead you out of the maze, so you then start searching in Portion B Backtracking

Clearly, at a single junction you could have even more than 2 choices. The backtracking strategy says to try each choice, one after the other, – if you ever get stuck, "backtrack" to the junction and try the next choice. If you try all choices and never found a way out, then there IS no solution to the maze. Junction B C A Backtracking

Backtracking (animation) start? ? dead end ? ? ? success! dead end

Backtracking Dealing with the maze: – From your start point, you will iterate through each possible starting move. – From there, you recursively move forward. – If you ever get stuck, the recursion takes you back to where you were, and you try the next possible move. Make sure you don't try too many possibilities, – Mark which locations in the maze have been visited already so that no location in the maze gets visited twice. – If a place has already been visited, there is no point in trying to reach the end of the maze from there again.

The neat thing about coding up backtracking is that it can be done recursively, without having to do all the bookkeeping at once. – Instead, the stack of recursive calls does most of the bookkeeping – (i.e., keeps track of which locations we’ve tried so far.) Backtracking

On to Complexity theory!

The $1M question The Clay Mathematics Institute Millennium Prize Problems 1.Birch and Swinnerton-Dyer Conjecture 2.Hodge Conjecture 3.Navier-Stokes Equations 4.P vs NP 5.Poincaré Conjecture 6.Riemann Hypothesis 7.Yang-Mills Theory

The P versus NP problem (informally) Can every problem whose solution can be quickly verified by a computer also be quickly solved by a computer?

What is an efficient algorithm? polynomial time O(n c ) for some constant c non-polynomial time Is an O(n) algorithm efficient? How about O(n log n)? O(n 2 ) ? O(n 10 ) ? O(n log n ) ? O(2 n ) ? O(n!) ?

The Class P (polynomial time) P Binary Search Breadth-First Search Dijkstra’s Algorithm Sorting Algorithms

NP (Nondeterministic Polynomial Time) Binary Search Breadth-First Search Dijkstra’s Algorithm Sorting Algorithms … P NP Hamilton Cycle Sudoku SAT …

The P versus NP problem Is one of the biggest open problems in computer science (and mathematics) today It’s currently unknown whether there exist polynomial time algorithms for NP-complete problems –We know P  NP, but does P = NP? –People generally believe P ≠ NP, but no proof yet What do these NP problems look like?

Sudoku 3x3x3

Sudoku 3x3x3

Sudoku 4x4x4

Sudoku 4x4x4

Suppose you have an algorithm S(n) to solve n x n x n V(n) time to verify the solution Fact: V(n) = O(n 2 x n 2 ) Question: is there some constant such that S(n) = O(n constant )? n x n x n... Sudoku

n x n x n... P vs NP problem = Does there exist an algorithm for solving n x n x n Sudoku that runs in time p(n) for some polynomial p( ) ?

The P versus NP problem (informally) Can every problem whose solution can be verified in polynomial time by a computer also be solved in polynomial time by a computer?

To check if a problem is in NP Phrase the problem as a yes/no question –If we can prove any yes instance is correct (in polynomial time), it is in NP –If we can also answer yes or no to the problem (in polynomial time) without being given a solution, it is in P

The Class P The class of all sets that can be verified in polynomial time. AND The class of all decision problems that can be decided in polynomial time. P Binary Search Breadth-First Search Dijkstra’s Algorithm Sorting Algorithms

NP Binary Search Breadth-First Search Dijkstra’s Algorithm Sorting Algorithms … P NP Hamilton Cycle Sudoku SAT … The class of all sets that can be verified in polynomial time.

Sudoku Input: n x n x n sudoku instance Output:YES if this sudoku has a solution NO if it does not The Set “SUDOKU” SUDOKU = { All solvable sudoku instances }

Hamilton Cycle Given a graph G = (V,E), is there a cycle that visits all the nodes exactly once? YES if G has a Hamilton cycle NO if G has no Hamilton cycle The Set “HAM” HAM = { graph G | G has a Hamilton cycle }

AND NOT Circuit-Satisfiability Input: A circuit C with one output Output:YES if C is satisfiable NO if C is not satisfiable The Set “SAT” SAT = { all satisfiable circuits C }

Verifying Membership Is there a short “proof” I can give you to verify that: G  HAM? G  Sudoku? G  SAT? Yes: I can just give you the cycle, solution, circuit

The Class NP The class of sets for which there exist “short” proofs of membership (of polynomial length) that can “quickly” verified (in polynomial time). Recall: The algorithm doesn’t have to find the proof; it just needs to be able to verify that it is a “correct” proof. Fact: P  NP

Summary: P versus NP P: in NP (membership verified in polynomial time) AND membership in a set can be decided in polynomial time. NP: “proof of membership” in a set can be verified in polynomial time. Fact: P  NP Question: Does NP  P ? i.e. Does P = NP? People generally believe P ≠ NP, but no proof yet

Why Care?

Classroom Scheduling Packing objects into bins Scheduling jobs on machines Finding cheap tours visiting a subset of cities Finding good packet routings in networks Decryption … NP Contains Lots of Problems We Don’t Know to be in P OK, OK, I care...

We would have to show that every set in NP has a polynomial time algorithm… How do I do that? It may take a long time! Also, what if I forgot one of the sets in NP? How could we prove that NP = P?

We can describe just one problem L in NP, such that if this problem L is in P, then NP  P. It is a problem that can capture all other problems in NP. The “Hardest” Set in NP We call these problems NP-complete How could we prove that NP = P?

Theorem [Cook/Levin] SAT is one problem in NP, such that if we can show SAT is in P, then we have shown NP = P. SAT is a problem in NP that can capture all other languages in NP. We say SAT is NP-complete.

Poly-time reducible to each other Oracle for problem X Oracle for problem Y Instance of problem Y Map instance of Y into instance of X Takes polynomial time Answer Any problem in NP SAT can be reduced (in polytime to) an instance of hence SAT is NP-complete Sudoku can be reduced (in polytime to) an instance of hence Sudoku is NP-complete

NP-complete: The “Hardest” problems in NP Sudoku SAT 3-Colorability Clique HAM Independent-Set These problems are all “polynomial-time equivalent” i.e., each of these can be reduced to any of the others in polynomial time If you get a polynomial-time algorithm for one, you get a polynomial-time algorithm for ALL. (you get millions of dollars, you solve decryption, … etc.)