Lecture 30. P, NP and NP Complete Problems 1. Recap Data compression is a technique to compress the data represented either in text, audio or image form.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
Problems and Their Classes
NP-Hard Nattee Niparnan.
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
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 
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.
Tractable and intractable problems for parallel computers
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
NP-complete and NP-hard problems
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Programming & Data Structures
MCS312: NP-completeness and Approximation Algorithms
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:
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
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.
חישוביות וסיבוכיות Computability and Complexity Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AAAA.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
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.
P, NP, and Exponential Problems Should have had all this in CS 252 – Quick review Many problems have an exponential number of possibilities and we can.
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.
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
Lecture 12 P and NP Introduction to intractability Class P and NP Class NPC (NP-complete)
NP-Complete Problems Algorithm : Design & Analysis [23]
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
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.
Week 13 - Monday.  What did we talk about last time?  B-trees  Hamiltonian tour  Traveling Salesman Problem.
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.
CS 3813: Introduction to Formal Languages and Automata Chapter 14 An Introduction to Computational Complexity These class notes are based on material from.
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.
Chapter 15 P, NP, and Cook’s Theorem. 2 Computability Theory n Establishes whether decision problems are (only) theoretically decidable, i.e., decides.
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.
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.
Algorithm Complexity By: Ashish Patel and Alex Golebiewski.
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.
CSC 172 P, NP, Etc.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
NP-Complete Problems.
Part VI NP-Hardness.
ICS 353: Design and Analysis of Algorithms
NP-Complete Problems.
RAIK 283 Data Structures & Algorithms
Presentation transcript:

Lecture 30. P, NP and NP Complete Problems 1

Recap Data compression is a technique to compress the data represented either in text, audio or image form. Two important compress techniques are lossy and lossless compression. LZW is the foremost technique for general purpose data compression due to its simplicity and versatility. LZW compression uses a code table, with 4096 as a common choice for the number of table entries. 2

Optimization & Decision Problems Decision problems – Given an input and a question regarding a problem, determine if the answer is yes or no Optimization problems – Find a solution with the “best” value Optimization problems can be cast as decision problems that are easier to study – E.g.: Shortest path: G = unweighted directed graph Find a path between u and v that uses the fewest edges Does a path exist from u to v consisting of at most k edges? 3

Algorithmic vs Problem Complexity The algorithmic complexity of a computation is some measure of how difficult is to perform the computation (i.e., specific to an algorithm) The complexity of a computational problem or task is the complexity of the algorithm with the lowest order of growth of complexity for solving that problem or performing that task. – e.g. the problem of searching an ordered list has at most lgn time complexity. Computational Complexity: deals with classifying problems by how hard they are. 4

Computational Complexity Theory In computer science, computational complexity theory is the branch of the theory of computation that studies the resources, or cost, of the computation required to solve a given computational problem. The relative computational difficulty of computable functions is the subject matter of computational complexity. Complexity theory analyzes the difficulty of computational problems in terms of many different computational resources. Example: looking up something in a dictionary has only logarithmic complexity because a double sized dictionary only has to be opened one time more (e.g. exactly in the middle - then the problem is reduced to the half). 5

Complexity Classes A complexity class is the set of all of the computational problems which can be solved using a certain amount of a certain computational resource. The complexity class P is the set of decision problems that can be solved by a deterministic machine in polynomial time. This class corresponds to an intuitive idea of the problems which can be effectively solved in the worst cases. The complexity class NP is the set of decision problems that can be solved by a non-deterministic machine in polynomial time. This class contains many problems that people would like to be able to solve effectively. All the problems in this class have the property that their solutions can be checked effectively. 6

Complexity Classes (taxonomy) Decision Problem Undecidable Type 0 (recursively enumerable) Decidable PSPACE Type 1 (context sensitive) PSPACE-Complete Co-NP NP NP-Complete P P-Complete Type 2 (context free) Type 3 (regular) Strict subset relationship Set equality is unknown 7

Deterministic (Turing) Machine Deterministic or Turing machines are extremely basic symbol-manipulating devices which — despite their simplicity — can be adapted to simulate the logic of any computer that could possibly be constructed. They were described in 1936 by Alan Turing. Though they were intended to be technically feasible, Turing machines were not meant to be a practical computing technology, but a thought experiment about the limits of mechanical computation; thus they were not actually constructed. Studying their abstract properties yields many insights into computer science and complexity theory. Turing machines capture the informal notion of effective method in logic and mathematics, and provide a precise definition of an algorithm or 'mechanical procedure'. 8

Nondeterministic (Turing) Machine In theoretical computer science, a non- deterministic Turing machine (NTM) is a Turing machine whose control mechanism works like a non-deterministic finite automaton. An ordinary (deterministic) Turing machine (DTM) has a transition function that, for a given state and symbol under the tape head, specifies three things: – the symbol to be written to the tape – the direction (left or right) in which the head should move – the subsequent state of the finite control An NTM differs in that the state and tape symbol no longer uniquely specify these things - many different actions may apply for the same combination of state and symbol. 9

Complexity Class P P is the complexity class containing decision problems which can be solved by a deterministic Turing machine using a polynomial amount of computation time, or polynomial time. P is often taken to be the class of computational problems which are "efficiently solvable" or "tractable“. Problems that are solvable in theory, but cannot be solved in practice, are called intractable. There exist problems in P which are intractable in practical terms; for example, some require at least n operations. P is known to contain many natural problems, including the decision versions of linear programming, calculating the greatest common divisor, and finding a maximum matching. In 2002, it was shown that the problem of determining if a number is prime is in P. 10

Complexity Class NP In computational complexity theory, NP ("Non-deterministic Polynomial time") is the set of decision problems solvable in polynomial time on a non-deterministic Turing machine. It is the set of problems that can be "verified" by a deterministic Turing machine in polynomial time. All the problems in this class have the property that their solutions can be checked effectively. This class contains many problems that people would like to be able to solve effectively, including – the Boolean satisfiability problem (SAT) – the Hamiltonian path problem (special case of TSP) – the Vertex cover problem. 11

Complexity Class NP-Complete In complexity theory, the NP-complete problems are the most difficult problems in NP ("non-deterministic polynomial time") in the sense that they are the ones most likely not to be in P. If one could find a way to solve any NP-complete problem quickly (in polynomial time), then they could use that algorithm to solve all NP problems quickly. At present, all known algorithms for NP-complete problems require time that is super polynomial in the input size. To solve an NP-complete problem for any nontrivial problem size, generally one of the following approaches is used: – Approximation – Probabilistic – Special cases – Heuristic 12

Complexity Class NP-Complete (cont) Some well-known problems that are NP- complete are: – Boolean satisfiability problem (SAT) – N-puzzle – Knapsack problem – Hamiltonian cycle problem – Traveling salesman problem – Subgraph isomorphism problem – Subset sum problem – Clique problem – Vertex cover problem – Independent set problem – Graph coloring problem – Minesweeper 13

Complexity Classes P and NP 14

Class of “P” Problems Class P consists of (decision) problems that are solvable in polynomial time Polynomial-time algorithms – Worst-case running time is O(n k ), for some constant k Examples of polynomial time: – O(n 2 ), O(n 3 ), O(1), O(n lg n) Examples of non-polynomial time: – O(2 n ), O(n n ), O(n!) 15

Tractable/Intractable Problems Problems in P are also called tractable Problems not in P are intractable or unsolvable – Can be solved in reasonable time only for small inputs – Or, can not be solved at all Are non-polynomial algorithms always worst than polynomial algorithms? - n 1,000,000 is technically tractable, but really impossible - n log log log n is technically intractable, but easy 16

Example of Unsolvable Problem Turing discovered in the 1930’s that there are problems unsolvable by any algorithm. The most famous of them is the halting problem – Given an arbitrary algorithm and its input, will that algorithm eventually halt, or will it continue forever in an “infinite loop?” 17

Examples of Intractable Problems 18

Intractable Problems Can be classified in various categories based on their degree of difficulty, e.g., – NP – NP-complete – NP-hard Let’s define NP algorithms and NP problems 19

Nondeterministic and NP Algorithms Nondeterministic algorithm = two stage procedure: 1) Nondeterministic (“guessing”) stage: generate randomly an arbitrary string that can be thought of as a candidate solution (“certificate”) 2) Deterministic (“verification”) stage: take the certificate and the instance to the problem and returns YES if the certificate represents a solution NP algorithms (Nondeterministic polynomial) verification stage is polynomial 20

Class of “NP” Problems Class NP consists of problems that could be solved by NP algorithms – i.e., verifiable in polynomial time If we were given a “certificate” of a solution, we could verify that the certificate is correct in time polynomial to the size of the input Warning: NP does not mean “non-polynomial” 21

Hamiltonian Cycle Given: a directed graph G = (V, E), determine a simple cycle that contains each vertex in V – Each vertex can only be visited once Certificate: – Sequence:  v 1, v 2, v 3, …, v |V|  hamiltonian not hamiltonian 22

Is P = NP? Any problem in P is also in NP: P  NP The big (and open question) is whether NP  P or P = NP – i.e., if it is always easy to check a solution, should it also be easy to find a solution? Most computer scientists believe that this is false but we do not have a proof … P NP 23

NP-Completeness (informally) NP-complete problems are defined as the hardest problems in NP Most practical problems turn out to be either P or NP-complete. Study NP-complete problems … P NP NP-complete 24

Summary Decision problems – Given an input and a question regarding a problem, determine if the answer is yes or no Optimization problems – Find a solution with the “best” value NP-complete - means problems that are 'complete' in NP, i.e. the most difficult to solve in NP NP-hard - stands for 'at least' as hard as NP (but not necessarily in NP); NP-easy - stands for 'at most' as hard as NP (but not necessarily in NP); NP-equivalent - means equally difficult as NP, (but not necessarily in NP); 25

In next Lecture In next lecture, we will revised the first fifteen lectures. 26