P, NP and more.

Slides:



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

Lecture # 38 Algorithms & Problem Solving: How Hard Can it Get?
1 The Limits of Computation Intractable and Non-computable functions.
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 
Great Theoretical Ideas in Computer Science for Some.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
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.
NP-complete and NP-hard problems. Decision problems vs. optimization problems The problems we are trying to solve are basically of two kinds. In decision.
1.1 Chapter 1: Introduction What is the course all about? Problems, instances and algorithms Running time v.s. computational complexity General description.
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:
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,
Scott Perryman Jordan Williams.  NP-completeness is a class of unsolved decision problems in Computer Science.  A decision problem is a YES or NO answer.
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.
Difficult Problems. Polynomial-time algorithms A polynomial-time algorithm is an algorithm whose running time is O(f(n)), where f(n) is a polynomial A.
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.
Chapter 7 Inefficiency and Intractability CS 345 Spring Quarter, 2014.
FACULTY OF ENGINEERING & INFORMATION TECHNOLOGIES P, NP, and Complexity Six fundamental facts One rule of thumb Three fundamental notions One fundamental.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Problems you shouldn’t tackle. Problem Complexity.
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.
Complexity A decidable problem is computationally solvable. But what resources are needed to solve the problem? –How much time will it require? –How much.
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.
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.
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.
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.
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
CS10: The Beauty and Joy of Computing Lecture #22 Limits of Computing Warning sign posted at Stern Hall. Also, Apple releases new operating.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
Computability Heap exercise. The class P. The class NP. Verifiers. Homework: Review RELPRIME proof. Find examples of problems in NP.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
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.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
The Beauty and Joy of Computing Lecture #23 Limits of Computing Researchers at Facebook and the University of Milan found that the avg # of “friends” separating.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 7 Time Complexity Some slides are in courtesy.
NP-Completeness  For convenience, the theory of NP - Completeness is designed for decision problems (i.e. whose solution is either yes or no).  Abstractly,
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
1 Computability Tractable, Intractable and Non-computable functions.
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.
Chapter 10 NP-Complete Problems.
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Chapter 11 Limitations of Algorithm Power
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
Presentation transcript:

P, NP and more

Towers of Hanoi Goal: transfer all n disks from peg A to peg C Rules: move one disk at a time never place larger disk above smaller one Recursive solution: transfer n - 1 disks from A to B move largest disk from A to C transfer n - 1 disks from B to C Total number of moves: T(n) = 2T(n - 1) + 1

Towers of Hanoi (2) Recurrence relation: Solution by unfolding: T(n) = 2 T(n - 1) + 1 T(1) = 1 Solution by unfolding: T(n) = 2 (2 T(n - 2) + 1) + 1 = = 4 T(n - 2) + 2 + 1 = = 4 (2 T(n - 3) + 1) + 2 + 1 = = 8 T(n - 3) + 4 + 2 + 1 = ... = 2i T(n - i) + 2i-1 +2i-2 +...+21 +20 the expansion stops when i = n - 1 T(n) = 2n – 1 + 2n – 2 + 2n – 3 + ... + 21 + 20

Towers of Hanoi (3) This is a geometric sum, so that we have T(n) = 2n - 1 = O(2n) The running time of this algorithm is exponential (kn) rather than polynomial (nk), where n is input size. Good or bad news? the Tibetans were confronted with a tower problem of 64 rings... Assuming the priests move one ring per second, it would take ~585 billion years to complete the process!

Traveling Salesman Problem Given a set of cities, distances between all pairs of cities, and a bound B, does there exist a tour (sequence of cities to visit) that returns to the start and requires at most distance B to be traveled? TSP is in NP: given a candidate solution (a tour), add up all the distances and check if total is at most B

Last Time The two theorems we proved showed an important distinction. The difference between a single and multi-tape TM is at most a square (or polynomial) difference. Moving to a nondeterministic TM gave an exponential speedup.

Polynomial Time From the perspective of time complexity, polynomial differences are considered small, whereas exponential differences are large. Exponential functions do grow incredibly fast; they grow much faster than any polynomial function. However, different polynomials grow much faster than others. In an algorithms course, you would be crazy to suggest that they are equivalent: O(n log n) sorting algorithms are much better than O(n2) algorithms. O(n) and O(n2) are radically different. Nonetheless, there are some good reasons for assuming polynomial-time equivalence.

Polynomial Time Algorithms What’s about? Halting problem Is your program slow or is in in infinite loop? (Can compiler help you?) Chess (40 to 200 moves  ~ 400 positions) Very bushy trees (even with alpha-beta pruning) Not P

Reasonable vs. Unreasonable Processing 1 elements takes 0.01 sec Number of microseconds

Reasonable vs. Unreasonable ”Good”, reasonable algorithms algorithms bound by a polynomial function nk Tractable problems ”Bad”, unreasonable algorithms algorithms whose running time is above nk Intractable problems intractable problems tractable problems problems not admitting reasonable algorithms problems admitting reasonable (polynomial-time) algorithms

Background Exponential-time algorithms arise when we solve problems by exhaustively searching a space of possible solutions using brute force search. Polynomial-time algorithms require something other than brute force. All reasonable computational models are polynomially-time equivalent. So if we view all polynomial complexity algorithms as equivalent, then the specific computational model doesn't matter.

Definition of the class P P is the class of languages that are decidable in polynomial time on a deterministic single-tape TM: That is:

The importance of P P plays a central role in the theory of computation because: P is invariant over all models of computation that are polynomially equivalent to a single-tape DTM. P roughly corresponds to the class of problems that are realistically solvable on a computer. Take this with a grain of salt. Some polynomial-time algorithms are bad: O(n10000) or 100000000000n2. Exponential algorithms may be okay for small n.

Verifying a Candidate Solution Suppose that you are organizing housing accommodations for a group of four hundred university students. Space is limited and only one hundred of the students will receive places in the dormitory. To complicate matters, the Dean has provided you with a list of pairs of incompatible students, and requested that no pair from this list appear in your final choice. Solving a problem: find possible people-room distribution? Verifying a candidate solution: given a possible people-room distribution, verify whether it is correct?

Verifying a Candidate Solution vs. Solving a Problem Intuitively it seems much harder (more time consuming) in some cases to solve a problem from scratch than to verify that a candidate solution actually solves the problem. If there are many candidate solutions to check, then even if each individual one is quick to check, overall it can take a long time

Verifying a Candidate Solution Many practical problems in computer science, math, operations research, engineering, etc. are polynomial time verifiable but have no known polynomial time algorithm Wikipedia lists problems in computational geometry, graph theory, network design, scheduling, databases, program optimization and more

Decision problems Are such long running times linked to the size of the solution of an algorithm? No! To show that, we in the following consider only TRUE/FALSE or yes/no problems – decision problems We can usually transform an optimization problem into an easier decision problem: Optimization problem O : “Find a shortest path between vertices u and v in a graph G.” Related decision problem D : “Determine if there is a path between vertices u and v in a graph G shorter than k.” If we have an easy way to solve O, we can use it to solve D. If we show that D is hard, we know that O must be also hard.

The Class P Why is it reasonable to consider all problems in P as tractable (i.e., "easy")? What about n5000? If is not in P, then it certainly is not easy Polynomial time is mathematically convenient for defining a class closed under composition Model independent notion poly time reductions between various formal models In practice, exponent is often small

The Class NP First, NP does not stand for not-P!! NP is the class of problems for which a candidate solution can be verified in polynomial time (nondeterministic solution in poly time) P is a subset of NP

More definitions P. Problems that can be solved in polynomial time. ("P" stands for polynomial.) These problems have formed the main material of this course. NP. This stands for "nondeterministic polynomial time" where nondeterministic is just a fancy way of talking about guessing a solution. A problem is in NP if you can quickly (in polynomial time) test whether a solution is correct (without worrying about how hard it might be to find the solution). Problems in NP are still relatively easy: if only we could guess the right solution, we could then quickly test it. NP does not stand for "non-polynomial". There are many complexity classes that are much harder than NP.

P vs. NP Although polynomial time verifiability seems like a weaker condition than polynomial time solvability, no one has been able to prove that it is weaker (describes a larger class of problems) So it is unknown whether P = NP if 'yes'-answers to a 'yes'-or-'no'-question can be verified "quickly" (in polynomial time), can the answers themselves also be computed quickly? one of seven millennium prize problems if you solve it you will get $1,000,000 http://www.claymath.org/millennium/P_vs_NP/

P and NP all problems P NP or P=NP

The Main Question If P=NP, then: Efficient algorithms for TSP, etc. Cryptography is impossible on conventional machines Modern banking system will collapse

The Main Question Yes? No? But maybe yes, since: Thousands of researchers have spent four decades in search of polynomial algorithms for many fundamental NP-complete problems without success Consensus opinion: P ¹ NP But maybe yes, since: No success in proving P ¹ NP either

The Big Picture Summarizing: it is not known whether NP problems are tractable or intractable But, there exist provably intractable problems Even worse – there exist problems with running times unimaginably worse than exponential! More bad news: there are provably noncomputable (undecidable) problems There are no (and there will not ever be!!!) algorithms to solve these problems

Why should we care? Difficult problems come up all the time. Knowing they're hard lets you stop beating your head against a wall trying to solve them, and do something better: Use a heuristic (solving a reasonable fraction of the common cases) Solve the problem approximately instead of exactly. Use an exponential time solution anyway. If you really have to solve the problem exactly, you can settle down to writing an exponential time algorithm and stop worrying about finding a better solution. Choose a better abstraction. The NP-complete abstract problem you're trying to solve presumably comes from ignoring some of the seemingly unimportant details of a more complicated real world problem. Perhaps some of those details shouldn't have been ignored, and make the difference between what you can and can't solve.

P = NP Question Open question since about 1970 Great theoretical interest Great practical importance: If your problem is NP-complete, then don't waste time looking for an efficient algorithm Instead look for efficient approximations, heuristics, etc.