CSE332: Data Abstractions Lecture 27: A Few Words on NP Tyler Robison Summer 2010 1.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

P, NP, NP-Complete Problems
Introduction to Algorithms NP-Complete
NP-Hard Nattee Niparnan.
Lecture 24 Coping with NPC and Unsolvable problems. When a problem is unsolvable, that's generally very bad news: it means there is no general algorithm.
The Theory of NP-Completeness
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
CSE373: Data Structures & Algorithms Lecture 24: The P vs. NP question, NP-Completeness Nicki Dell Spring 2014 CSE 373 Algorithms and Data Structures 1.
Computational problems, algorithms, runtime, hardness
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
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Circuits CSE 373 Data Structures Lecture 22. 3/12/03Circuits - Lecture 222 Readings Reading ›Sections and 9.7.
CS10 The Beauty and Joy of Computing Lecture #23 : Limits of Computing Thanks to the success of the Kinect, researchers all over the world believe.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Programming & Data Structures
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:
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.
Great Theoretical Ideas in Computer Science.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
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.
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.
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.
CSE332: Data Abstractions Lecture 24.5: Interlude on Intractability Dan Grossman Spring 2012.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Cliff Shaffer Computer Science Computational Complexity.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
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.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
NP-Complete problems.
NP-complete Problems Prof. Sin-Min Lee Department of Computer Science.
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.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 7 Time complexity Contents Measuring Complexity Big-O and small-o notation.
Fundamentals of Informatics Lecture 14 Intractability and NP-completeness Bas Luttik.
CPS Computational problems, algorithms, runtime, hardness (a ridiculously brief introduction to theoretical computer science) Vincent Conitzer.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
CS 461 – Nov. 18 Section 7.1 Overview of complexity issues –“Can quickly decide” vs. “Can quickly verify” Measuring complexity Dividing decidable languages.
1 CSE 326: Data Structures: Graphs Lecture 24: Friday, March 7 th, 2003.
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
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
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.
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.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
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
P & NP.
Hard Problems Introduction to NP
Chapter 11 Limitations of Algorithm Power
CSE 589 Applied Algorithms Spring 1999
Presentation transcript:

CSE332: Data Abstractions Lecture 27: A Few Words on NP Tyler Robison Summer

Easily one of the most important questions in Computer Science: 2 Does P=NP?  Of course, we need to go into what these terms mean  P and NP are classes of problems  P: Class of problems that can be solved in polynomial time  NP: Class of problems where an answer can be verified in polynomial time  We’ll get into what that means  The question is, are these sets equivalent?  A question that computer scientists & mathematicians have been grappling with for a long time  Most believe that P!=NP, but no one’s proven it  One such proof recently in the news (P!=NP; probably not valid)

Wow, that’s fantastic… who cares? 3  P=NP would mean that many ‘difficult’ problems that could previously only be solved in exponential time could now be solved in polynomial time  Some algorithms (such as cryptography) are based around the ‘difficulty’ of brute-forcing it, but the ease of which an answer can be verified  You can break many online encryptions now… with enough computing power  Say, an enormous # of computers  Or one computer running for several centuries  And you don’t break the scheme itself; you break it for a single session  If P=NP, much of existing cryptography would (in theory) be insecure

Why, cont. 4  Proving equivalence (or non equivalence) of two problem classes interesting mathematically  Proving (or disproving) P = NP is among the most vexing and important open questions in computer science and probably mathematics  A $1M prize, the Turing Award, and eternal fame await  Sort of the “Fermat’s Last Theorem” of the CS world (except, this is unsolved)

Topic doesn’t really belong in CSE332 5  This lecture mentions some highlights of NP, the P vs. NP question, and NP-completeness  It should not be part of CSE332:  We don’t spend enough time to do it justice  To really cover it, a much larger block of time is needed, and after relevant theory background  It’s not on the final  But you are all (?) “in transition”  Due to recent shifting around of CS curriculum  Encourage you to take Algorithms or Theory to learn more  Remember the Dijsktra’s quote : “computer science is no more about computers than astronomy is about telescopes” – they are quite relevant here  Anyway, next academic year, this lecture drops out of CSE332  And, it’s an interesting (& important) problem

P 6  P: The class of problems that can be solved by algorithms running in polynomial time; O(n k ) for some constant k  Note: For purposes of this discussion, consider logn, nlogn, etc. as roughly the same as polynomial: nlogn < n 2, so it’s ‘about that fast’  Contrast with exponential time: very, very slow  Every problem we have studied is in P  Examples: Sorting, minimum spanning tree, …  Yet many problems don’t have efficient algorithms!  While we may have been quite concerned with getting sorting down from O(n 2 ) to O(nlogn), in the grand scheme of things, both are pretty good  Really, polynomial time is sufficiently ‘quick’  Yes, even something insane like O(n )  Exponential time is not; very quickly becomes infeasible to solve (precisely, anyway)

NP 7  NP: The class of problems for which polynomial time algorithms exist to check that an answer is correct  Given this potential answer, can you verify that it’s correct in polynomial time?  To solve from scratch, we only know algorithms that can do it in exponential time  If P=NP, then that would mean we’d have polynomial time algorithms for solving NP problems  Ex: We saw Dijkstra’s algorithm for finding shortest path in polynomial time  For an unweighted graph, finding the longest path (that doesn’t repeat vertices) is in NP  There is a bit more to it than that; need to modify the problem slightly

More NP 8  We know P  NP  That is, if we already know how to solve a problem in polynomial time, we can verify a solution for it in polynomial time too  NP stands for “non-deterministic polynomial time” for technical reasons  Many details being left out, but this is the gist  There are many important problems for which:  We know they are in NP (we can verify solutions in polynomial time)  We do not know if they are in P (but we highly doubt it)  The best algorithms we have to solve them are exponential  O(k n ) for some constant k

NP Example One: Satisfiability 9  Input: a logic formula of size m containing n variables  Various logical ands, ors, nots, implications, etc.  Can assign true or false to each variable, evaluate according to rules, etc.  Output: An assignment of Boolean values to the variables in the formula such that the formula is true  That is, find an assignment for x1, x2, … xn such that the equation is true; if such an assignment exists  A good problem to solve, in that you can use logic to represent many other problems  An older branch of AI looked into encoding an agent’s knowledge this way, then reasoning about the world by evaluating expressions

NP Example One: Satisfiability 10  We can solve it via ‘brute-force’:  Try every possible variable assignment  {x1=true,x2=true,…xn=true}, {x1=false…}…  How many possibilities do we need to try?  n variables, 2 possible values for each, so 2 n possible assignments  Not so bad for n=5… looking less bright for n=1,000  So exponential time to solve by checking all possibilities  We can verify it quickly though  If I give you an assignment {x1=false, x2=….}, you can do it in polynomial time: just evaluate the expression  If P=NP, a O(m k n k ) algorithm to solve this exists

NP Example One: Satisfiability 11  Quite a few NP problems are like this in that they:  Are relatively simple to explain  Can be solved easily but slowly by brute-force: simply try all possibilities

NP Example Two: Subset sum 12 Input: An array of n numbers and a target-sum sum Output: A subset of the numbers that add up to sum if one exists O(2 n ) algorithm: Try every subset of array O(n k ) algorithm: Unknown, probably does not exist Verifying a solution: Given a subset that allegedly adds up to sum, add them up in O(n) ?

NP Example Three: Vertex Cover (modified) 13 Input: A graph (V,E) and a number m Output: A subset S of V such that for every edge ( u, v ) in E, at least one of u or v is in S and |S|=m (if such an S exists) That is, every vertex in the graph is ‘covered’ by being in S, or being adjacent to something in S, and the size of S is m O(2 m ) algorithm: Try every subset of vertices of size m O(m k ) algorithm: Unknown, probably does not exist Verifying a solution: See if S has size m and covers edges

NP Example Four: Traveling Salesman 14 Input: A complete directed graph (V,E) and a number m. Say, a graph of cities with edges as travel times Output: A path that visits each vertex exactly once and has total cost < m if one exists O(2 |V| ) algorithm: Try every valid path including all vertices; pick one of cost m O(|V| k ) algorithm: Unknown, probably does not exist Verifying a solution: Traverse the graph in that order, keep track of the cost as you go; at the end, compare against m

More? 15  Thousands of different problems that:  Have real applications  Nobody has polynomial algorithms for  Widely believed: None of these problems have polynomial algorithms  That is, P!=NP  For optimal solutions, but some can be approximated more efficiently

NP-Completeness 16 What we have been able to prove is that many problems in NP are actually NP-complete (one sec for why that’s important) To be NP-complete, needs to have 2 properties: 1. Be in NP (that is, a solution to it can be verified in polynomial time) 2. Be NP-hard: On an intuitive level, being NP-hard means that it is at least as hard as any other problem in NP  What it boils down to: If we have a polynomial time solution to an NP-hard problem, we can alter it to solve any problem in NP in polynomial time All four of our examples are NP-complete

P=NP ? 17  If we gave an algorithm that solved an NP-complete problem in polynomial time, we could then use it to solve all NP problems in polynomial time  Because of our definition of NP-complete  To show P=NP, you just need to find a polynomial time solution to a single NP-complete problem  Or, to show P!=NP, you need to show that no polynomial time algorithm exists for a particular NP problem

Hard problems 18 There are problems in each of these categories:  We know how to solve efficiently  We do not know how to solve efficiently:  For example, NP-complete problems  We know we cannot solve efficiently (exponential time): see a Theory course  We know we cannot solve at all: see CSE311/CSE322  The Halting Problem A key art in computer science: When handed a problem, figure out which category it is in!