Computational Complexity

Similar documents
Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

NP Complete Problems. COMP 215 Lecture 20

Polynomial-time reductions. We have seen several reductions:

Limitations of Algorithm Power

Introduction to Complexity Theory

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Analysis of Algorithms. Unit 5 - Intractable Problems

1. Introduction Recap

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

P, NP, NP-Complete, and NPhard

CMSC 441: Algorithms. NP Completeness

Tractable & Intractable Problems

Design and Analysis of Algorithms

NP-Completeness. Until now we have been designing algorithms for specific problems

P,NP, NP-Hard and NP-Complete

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Computational Complexity

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

CS 350 Algorithms and Complexity

CSC 8301 Design & Analysis of Algorithms: Lower Bounds

CS 350 Algorithms and Complexity

NP Completeness and Approximation Algorithms

Tractability. Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time?

DESIGN AND ANALYSIS OF ALGORITHMS. Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

The P-vs-NP problem. Andrés E. Caicedo. September 10, 2011

NP-Completeness. NP-Completeness 1

CSC 1700 Analysis of Algorithms: P and NP Problems

Correctness of Dijkstra s algorithm

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

Polynomial-time Reductions

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

Essential facts about NP-completeness:

Nondeterministic Polynomial Time

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

Computer Sciences Department

ECS122A Handout on NP-Completeness March 12, 2018

Algorithms Design & Analysis. Approximation Algorithm

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

NP and NP Completeness

Spring Lecture 21 NP-Complete Problems

Notes for Lecture 21

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

Review of unsolvability

Problems and Solutions. Decidability and Complexity

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

Intractable Problems [HMU06,Chp.10a]

Friday Four Square! Today at 4:15PM, Outside Gates

CS/COE

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

CS 583: Algorithms. NP Completeness Ch 34. Intractability

COSE215: Theory of Computation. Lecture 21 P, NP, and NP-Complete Problems

Data Structures in Java

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

Turing Machines and Time Complexity

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

1 Primals and Duals: Zero Sum Games

Chapter 3: Proving NP-completeness Results

SAT, NP, NP-Completeness

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

In complexity theory, algorithms and problems are classified by the growth order of computation time as a function of instance size.

NP-completeness. Chapter 34. Sergey Bereg

Lecture 4: NP and computational intractability

NP-Completeness Theory

Introduction to Computational Complexity

ECS 120 Lesson 24 The Class N P, N P-complete Problems

COSE215: Theory of Computation. Lecture 20 P, NP, and NP-Complete Problems

NP-Complete Problems. More reductions

Acknowledgments 2. Part 0: Overview 17

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Advanced topic: Space complexity

A Working Knowledge of Computational Complexity for an Optimizer

There are two types of problems:

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

NP-Complete Problems and Approximation Algorithms

VIII. NP-completeness

Computers and Intractability. The Bandersnatch problem. The Bandersnatch problem. The Bandersnatch problem. A Guide to the Theory of NP-Completeness

Introduction. Pvs.NPExample

Computers and Intractability

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

1 Reductions and Expressiveness

The Beauty and Joy of Computing

CS481: Bioinformatics Algorithms

SAT, Coloring, Hamiltonian Cycle, TSP

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

Notes on Complexity Theory Last updated: October, Lecture 6

Computational complexity theory

Quantum Complexity Theory. Wim van Dam HP Labs MSRI UC Berkeley SQUINT 3 June 16, 2003

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

INTRO TO COMPUTATIONAL COMPLEXITY

CS 5114: Theory of Algorithms

Theory of Computation Chapter 1: Introduction

BBM402-Lecture 11: The Class NP

Chapter Finding parse trees

Copyright 2000, Kevin Wayne 1

Principles of Computing, Carnegie Mellon University. The Limits of Computing

Transcription:

Computational Complexity Problems, instances and algorithms Running time vs. computational complexity General description of the theory of NP-completeness Problem samples 1

Computational Complexity What is computational complexity all about?: Tractability vs. intractability of problems Particular Topics: Turing machines, deterministic & non-deterministic Complexity classes P, NP, co-np, #P, and PSPACE NP-completeness, NP-hardness, #P-completeness, PSPACE-completeness Special cases and sub-problems Approximation algorithms, e.g., heuristics, & performance bounds 2

Computational Complexity What does it mean to say that a problem is intractable? There are a couple of different notions of intractability: undecidable no algorithm exists for the problem decidable there is an algorithm, but the only ones we know require exponential time to compute a solution Here, we will focus on the last category. 3

The Traveling Salesman Optimization Problem Recall that a problem is a general question to be answered. A problem consists of: Some number of parameters (a generic instance) A statement of what properties a solution possesses An example of a problem: TRAVELING SALESMAN OPTIMIZATION INSTANCE: Set C of m cities, distance d(c i, c j ) Z + for each pair of cities c i, c j C. GOAL: Find a tour of C (i.e., a permutation <c (1), c (2),, c (m) > of C) having minimum total length. Note the format! 4

TSP Optimization Instance A problem instance is a collection of specific values for all of a problems parameters. A TSP instance: c1 9 C = {c 1, c 2, c 3, c 4 } 5 3 c4 D(c 1,c 2 ) = 10 D(c 1,c 3 ) = 5 D(c 1,c 4 ) = 9 10 c3 6 9 D(c 2,c 3 ) = 6 D(c 2,c 4 ) = 9 D(c 3,c 4 ) = 3 c2 5

Problems, Instances and Algorithms Let denote a problem. The parameters for define a multi-dimensional data space (or collection) of instances referred to as D. Each point in this space represents one specific instance. 6

Problems, Instances and Algorithms Our definition of a problem is very general, and contains many useless problems: SILLY INTEGER COMPUTATION INSTANCE: Positive integer B. GOAL: Compute the largest prime number less than 1000. The question to be asked is usually in terms of the instance parameters. 7

Optimization vs. Decision Problems Many (natural) problems of interest are optimization problems. Minimization, maximization Although not as natural on the surface, the theory will focus on decision problems, which are problems that have yes or no answers. A decision problem consists of two parts: A list of parameters (i.e., a generic instance); defines a set D of instances. A yes/no question asked in terms of the parameters; specifies a subset of yes instances Y which is a subset of D. 8

The Traveling Salesman Decision Problem (TSP) TRAVELING SALESMAN INSTANCE: Set C of m cities, distance d(c i, c j ) Z + for each pair of cities c i, c j C positive integer B. QUESTION: Is there a tour of C having length B or less, I.e., a permutation <c (1), c (2),, c (m) > of C such that: m 1 i= 1 d( c ( i), c ( i + 1)) + d( c ( m), c (1)) B? 9

TSP Instance A TSP instance (decision version): C = {c 1, c 2, c 3, c 4 } D(c 1,c 2 ) = 10 D(c 1,c 3 ) = 5 D(c 1,c 4 ) = 9 D(c 2,c 3 ) = 6 D(c 2,c 4 ) = 9 D(c 3,c 4 ) = 3 c1 10 5 c3 6 9 3 9 c4 B = 27 c2 10

Optimization vs. Decision Problems Why decision problems? Convenience: defining the classes of problems P and NP is easier the proofs of NP-completeness are easier unreasonably large output does not affect running time or complexity. No loss of generality; results extend to optimization problems*** More specifically, most optimization problems can be converted to a decision problem by adding an additional parameter B. The complexity of an optimization problem is typically equivalent to that of a corresponding decision problem. 11

Running Time v.s. Complexity Recall the distinction between the running time of a specific algorithm vs. the computational complexity of a particular problem. Example: MATRIX MULTIPLICATION INSTANCE: Two n x n matrices A and B SOLUTION: One n x n matrix C = A x B Running times of specific algorithms: Simple row/column algorithm - O(n 3 ) Strassen s algorithm - O(n 2.807 ) Coppersmith-Winograd algorithm - O(n 2.3728639 ) 12

Running Time v.s. Complexity Recall the distinction between the running time of a specific algorithm vs. the computational complexity of a particular problem. Example: MATRIX MULTIPLICATION INSTANCE: Two n x n matrices A and B SOLUTION: One n x n matrix C = A x B The (inherent) computational complexity of matrix multiplication: Any algorithm for matrix multiplication requires (n 2 ), i.e, O(n 2 ) is the best any algorithm could possibly do (this is an information theoretic argument). 13

Running Time v.s. Complexity Example: INTEGER SORTING INSTANCE: List of n integers. SOLUTION: The list of integers in non-decreasing order. Running times of specific algorithms: Real dumb algorithm - O(n 3 ) Bubble sort - O(n 2 ) Merge sort - O(nlogn) The (inherent) computational complexity of sorting: Any comparison-based sorting algorithm requires (nlogn) operations in the worst case, i.e, O(nlogn) is the best any algorithm could possibly do. 14

The Satisfiability Problem (SAT) A very important problem in the theory of NP-completeness is the satisfiability problem. SATISFIABILITY INSTANCE: Set U of variables and a collection C of clauses over U. QUESTION: Is there a satisfying truth assignment for C? Example #1: U = {u 1, u 2 } C = {{ u 1, u 2 }, { u 1, u 2 }} Answer is yes - satisfiable by setting both variables T 15

The Satisfiability Problem (SAT) A very important problem in the theory of NP-completeness is the satisfiability problem. SATISFIABILITY INSTANCE: Set U of variables and a collection C of clauses over U. QUESTION: Is there a satisfying truth assignment for C? Example #2: U = {u 1, u 2 } C = {{ u 1, u 2 }, { u 1, u 2 }, { u 1 }} Answer is no 16

Satisfiability, Cont. What would be a simple algorithm for SAT? Build a truth table Running time would be (at least) O(n2 m ) m is the number of variables n is the length of the expression Is a more efficient algorithm possible? probably How about one with polynomial running time? Come see me if you find one! A live white turkey and a Stanford job awaits SAT was the first problem proven to be NP-complete 17

More Sample Problems CLIQUE INSTANCE: A Graph G = (V, E) and a positive integer J <= V. QUESTION: Does G contain a clique of size J or more? GRAPH K-COLORABILITY INSTANCE: A Graph G = (V, E) and a positive integer K <= V. QUESTION: Is the graph G K-colorable? These can similarly be solved in exponential time, but no one has ever found a polynomial time algorithm for either of them. These problems are also NP-complete. 18

General Points We are interested in the border between exponential and polynomial - given a problem, is there a polynomial time algorithm for it, or are all algorithms for it exponential in running time? We are not interested in what the specific polynomial or exponential is, per se, although the theory can be modified/refined to consider these. => Simplistically and inaccurately speaking, saying that a problem is NPcomplete or NP-hard is essentially saying that there is no (deterministic) polynomial time algorithm for that problem. 19

General Points, Cont. Polynomial time does not necessarily imply practical. O(n 1000 ) O(n 2 ) could be 10,000,000n 2 NP-complete/NP-hard does not necessarily imply that their aren t useful, practical algorithms. An algorithm could have worst-case running time O(2 n ) because of some small number of cases, but O(n 2 ) average Simplex algorithm for linear programming Branch-and-bound algorithm for knapsack problem. O( n) isn t all that bad. 2 20

General Points, Cont. Proving a problem is NP-complete or NP-hard is just the beginning: Heuristic development and analysis (the problem doesn t go away) Special cases of the problem may be solvable in polynomial time Sub-exponential time algorithms may exist. 21

General Description of the Theory NP consists of those decision problems that can be solved in Nondeterministic Polynomial time Holy cow! What is that, and how could it be possibly be important? NP Put simply, NP is a big set of many very common and useful problems. An important fact is that all of these problem can be solved in (deterministic) exponential time, i.e., there is an exponential time algorithm to solve them. 22

General Description of the Theory P consists of those problems from NP that can (also) be solved in deterministic polynomial time. P NP P NP P is also a very big set of common and useful problems, but these we know can be solving in deterministic polynomial time. 23

General Description of the Theory So now we know two things: All problems in NP can be solved in exponential time All problems in P can be solved in polynomial time (as well as exponential time) P NP Question - what would it mean for a problem to be in NP - P? This would be a problem that could be solved in exponential time, but not in polynomial time, i.e., it would be a hard problem. 24

General Description of the Theory Do any such problems exist, in NP- P? Nobody knows This is actually the big question, is P NP, or is P = NP? P NP The answer to this question appears to be P NP, i.e., there exist problems in NP for which there is no known (deterministic) polynomial time algorithm. 25

More Sample Problems DIVISIBILITY BY 2 INSTANCE: Integer k. QUESTION: Is k even? CLIQUE INSTANCE: A Graph G = (V, E) and a positive integer J <= V. QUESTION: Does G contain an independent set of size J or more? KNAPSACK INSTANCE: A finite set U, a size s(u) Z + and a value v(u) Z + for each u U, a size constraint B Z +, and a value goal k Z +. QUESTION: Is there a subset U U such that: σ u U s(u) B and σ u U v(u) K 26

General Description of the Theory There is another subset of problems in NP called NP-complete. NP-complete NP P The above diagram implies several relationships: P and NP-complete are subsets of NP (fact) P and NP-complete are proper subsets of NP (unproven, widely believed) P and NP-complete do not intersect (unproven, widely believed) Why is this set NP-complete important? 27

Facts about NP-complete Problems Some basic facts about NP-complete problems Suppose is an NP-complete problem. NP-complete P NP Fact #1: can be solved in exponential time. Fact #2: There are no known polynomial time algorithms for ; all known algorithms require exponential time, e.g., exhaustive search Fact #3: It is not known for certain whether requires exponential time or not. All NP-complete problems appear to require exponential time, but only because no polynomial time algorithm has been found for any of them. Fact #4: If P then P = NP No such NP-complete problem has ever been identified. 28

Facts about NP-complete Problems If a problem is NP-complete it is a big deal because: it is unlikely there is a polynomial-time algorithm for it if there were, everything in NP could be solved in polynomial time! Because of this, it is frequently said that NP-complete problems are the hardest problems in NP. Since the set of NP-complete problems contains many very practical problems that people have tried (and failed) to come up with polynomial time algorithms for, it is highly unlikely that any NP-complete problem can be solved in polynomial time. 29

Facts about NP-complete Problems Given a problem, we would like to know if P or NP-complete. How do we show a problem is in NP? develop a non-deterministic polynomial time algorithm for it (BTSOTC) If we know a problem is in NP, how do we show it is also in P? come up with a (deterministic) polynomial time algorithm for it (BTDT) If we can t find a polynomial time algorithm for it, how do we show a problem is (in) NP-complete? Use a proof technique called a deterministic polynomial time transformation to the problem from a known NP-complete problem (BTSOTC) 30

More Sample Problems CLIQUE INSTANCE: A Graph G = (V, E) and a positive integer J <= V. QUESTION: Does G contain a clique of size J or more? GRAPH K-COLORABILITY INSTANCE: A Graph G = (V, E) and a positive integer K <= V. QUESTION: Is the graph G K-colorable? These can similarly be solved in exponential time, but no one has ever found a polynomial time algorithm for either of them. These problems are also NP-complete. 31

Problems, Instances and Algorithms And, by the way An algorithm is a general, step-by-step procedure for solving a specific problem, e.g., a computer program. An algorithm is said to solve a problem if that algorithm can be applied to any instance of the problem and is guaranteed to always produce a solution for that instance. 32