Theory of Computation Chapter 1: Introduction

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

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

Computational complexity theory

P, NP, NP-Complete, and NPhard

Computational complexity theory

Unit 1A: Computational Complexity

NP-Completeness. NP-Completeness 1

Computational Complexity

Chapter 3. Complexity of algorithms

Growth of Functions (CLRS 2.3,3)

Design and Analysis of Algorithms

Introduction to Complexity Theory

Computational Complexity

Graph Theory and Optimization Computational Complexity (in brief)

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

Algorithms. Grad Refresher Course 2011 University of British Columbia. Ron Maharik

Limitations of Algorithm Power

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu

Big O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013

Data Structures and Algorithms Running time and growth functions January 18, 2018

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

2. ALGORITHM ANALYSIS

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

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

COMPUTATIONAL COMPLEXITY

Non-Deterministic Time

Md Momin Al Aziz. Analysis of Algorithms. Asymptotic Notations 3 COMP Computer Science University of Manitoba

The Complexity of Maximum. Matroid-Greedoid Intersection and. Weighted Greedoid Maximization

Polynomial-time Reductions

CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

1a. Introduction COMP6741: Parameterized and Exact Computation

Martin Milanič

Applied Computer Science II Chapter 7: Time Complexity. Prof. Dr. Luc De Raedt. Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Analysis of Algorithms

Correctness of Dijkstra s algorithm

Space Complexity. Master Informatique. Université Paris 5 René Descartes. Master Info. Complexity Space 1/26

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

CSE 105 THEORY OF COMPUTATION

Peter Wood. Department of Computer Science and Information Systems Birkbeck, University of London Automata and Formal Languages

NP-Complete Problems. More reductions

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

2 Notation and Preliminaries

Computational Complexity III: Limits of Computation

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

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

Polynomial-Time Reductions

4/30/14. Chapter Sequencing Problems. NP and Computational Intractability. Hamiltonian Cycle

Ταουσάκος Θανάσης Αλγόριθμοι και Πολυπλοκότητα II 7 Φεβρουαρίου 2013

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

Data Structures and Algorithms. Asymptotic notation

NP and Computational Intractability

Computer Sciences Department

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

Computers and Intractability

3.1 Asymptotic notation

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

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

Travelling Salesman Problem

CIS 121 Data Structures and Algorithms with Java Spring Big-Oh Notation Monday, January 22/Tuesday, January 23

CSC Design and Analysis of Algorithms. Lecture 1

Approximation complexity of min-max (regret) versions of shortest path, spanning tree, and knapsack

Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness

Turing Machines and Time Complexity

NP-Completeness. Algorithmique Fall semester 2011/12

CS/COE

Analysis of Algorithms. Unit 5 - Intractable Problems

Computational Complexity

CS473 - Algorithms I

with the size of the input in the limit, as the size of the misused.

ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS

VIII. NP-completeness

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

Reductions. Reduction. Linear Time Reduction: Examples. Linear Time Reductions

Data Structures in Java

- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs

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

Intelligent Agents. Formal Characteristics of Planning. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University

Theory of Computer Science

Multiple Sequence Alignment: Complexity, Gunnar Klau, January 12, 2006, 12:

Time Complexity. CS60001: Foundations of Computing Science

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

NP-completeness. Chapter 34. Sergey Bereg

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

NP Completeness and Approximation Algorithms

Analysis of Algorithms

Theory of Computer Science. Theory of Computer Science. E1.1 Motivation. E1.2 How to Measure Runtime? E1.3 Decision Problems. E1.

Tractable & Intractable Problems

P, NP, NP-Complete. Ruth Anderson

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

A Simple Proof of P versus NP

Big-O Notation and Complexity Analysis

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

Space Complexity. then the space required by M on input x is. w i u i. F ) on. September 27, i=1

Data Structures and Algorithms (CSCI 340)

6-1 Computational Complexity

Problem Complexity Classes

Una descrizione della Teoria della Complessità, e più in generale delle classi NP-complete, possono essere trovate in:

Complexity. Complexity Theory Lecture 3. Decidability and Complexity. Complexity Classes

Transcription:

Theory of Computation Chapter 1: Introduction Guan-Shieng Huang Sep. 20, 2006 Feb. 9, 2009 0-0

Text Book Computational Complexity, by C. H. Papadimitriou, Addison-Wesley, 1994. 1

References Garey, M.R. and D.S. Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness. 1979: W. H. Freeman and Company. Ausiello, G., et al., Complexity and Approximation: Combinatorial Optimization Problems and Their Approximability Properties. 2003: Springer-Verlag. Vazirani, V.V., Approximation Algorithms. 2004: Springer Verlag. Sipser, M., Introduction to the Theory of Computation. 2 ed. 2005: Course Technology. Kozen, D.C., Theory of Computation. 2006: Springer Verlag. Goldreich, O., Computational Complexity: A Conceptual Perspective. 2008: Cambridge University Press. 2

Arora, S., Computational Complexity: A Modern Approach. Draft, 2006. (http://www.cs.princeton.edu/ arora/book/book.html) 3

Turing Machines (Chap. 2) Scope Computability (Chap. 3) Boolean Logic (Chap. 4) Relations Between Complexity Classes (Chap. 7) Reductions and Completeness (Chap. 8) NP-complete Problems (Chap. 9) NP and conp (Chap. 10) Primality Testing (Chap. 10) 4

Randomized Computation (Chap. 11) Cryptography (Chap. 12) Approximability (Chap. 13) 5

Graph Reachability Outline of Chap. 1 Maximum Flow Matching Traveling Salesman Problem 6

Graph Reachability Problem 1 Given a directed graph G = (V, E), where V = {1, 2,...,n}, ask whether there is a path from node 1 to node n. 1 4 1 4 5 5 2 3 2 3 1 4 3 5 7

1. Let S = {1}. Algorithm 2. If S is empty, go to 5; otherwise, remove one node, say t, in S. 3. For each edge (t, u) E, if u is not marked, mark u and add u to S. 4. Go to 2. 5. If node n is marked, answer yes ; otherwise answer no. 8

Problem 1.4.2 1. Show by induction on i that, if v is the ith node added by the search algorithm to the set S, then there is a path from node 1 to v. 2. Show by induction on l that if node v is reachable from node 1 via a path with l edges, then the search algorithm will add v to set S. 9

Example S t 1 4 5 {1} 1 {3, 4} 3 {5, 4} 4 2 3 {5} 5 {} 10

Complexity 1. Observe that each node can stay in S at most once. 2. Each edge is used at most once. 3. There are at most n 2 edges. 4. The time complexity is at most n 2. 5. Space complexity is n. 11

Remark 1. How to implement Step 2 in the algorithm? stack DFS, queue BFS 2. How to implement Step 3? Random access memory. 3. What is the computational model? 4. Big-O. 12

Big-O Let f and g be functions from N to N. We write f(n) = O(g(n)) if there are positive integers c and n 0 such that, for all n n 0, f(n) c g(n). 1. f(n) = O(g(n)) means intuitively that f grows as g or slower. 2. We write f(n) = Ω(g(n)) if g(n) = O(f(n)). 3. We write f(n) = Θ(g(n)) if f(n) = O(g(n)) and f(n) = Ω(g(n)). 13

1. n = O(n 2 ) 2. n 1.5 = O(n 2 ) Examples 3. If p(n) is a polynomial of degree d, then p(n) = Θ(n d ). 4. If c > 1 is a positive integer and p(n) any polynomial, then p(n) = O(c n ). 5. lg n = O(n), or (lg n) k = O(n). 14

1. f(n) = O(g(n)) if for some constant c. f(n) = O(g(n)) iff for some constant c. Determining Big-O lim n lim sup n f(n) g(n) c f(n) g(n) c 2. If f(n) = O(g(n)) and g(n) = O(h(n)), then f(n) = O(h(n)). (transitivity) 15

Problem 1.4.10 Let f(n) and g(n) be any two of the following functions. Determine whether (i) f(n) = O(g(n)); (ii) f(n) = Ω(g(n)); f(n) = Θ(g(n)): (a) n 2 ; (b) n 3 ; (c) n 2 log n; (d) 2 n ; (e) n n ; (f) n log n ; (g) 2 2n ; (h) 2 2n+1 ; (j) n 2 if n is odd, 2 n otherwise. It is easy to see that (a) (c) (b) (d) (e). Also, (f) (e), and (g) (h). 16

Polyniomial-Time Algorithm polynomial time practical, efficient exponential time impractical, inefficient (intractable) n 80 algorithm v.s. 2 n 100 algorithm worst case v.s. average case The exponential worst-case performance of an algorithm may due to a statistically insignificant fraction of the input. 17

Maximum Flow A network N = (V, E, s, t, c) is a graph (V, E) with two specified nodes s (the source) and t (the sink) such that the source has no incoming edges and the sink has no outgoing edges; for each edge (i, j), we are given a capacity c(i, j), a positive integer. 18

A Network 2 1 4 s 2 t 3 1 3 19

Flow 1. an assignment of a nonnegative integer value f(i, j) c(i, j) to each edge (i, j); 2. for each node, other than s and t, the sum of the fs of the incoming edges is equal to the sum of the outgoing edges; ( y i= y X ) 3. the value of a flow is the sum of the flows in the edges leaving s (or, equivalently, the sum coming to t). 20

Maximum Flow Problem Given a network, find a flow of the largest possible value. 2/1 1/1 4/3 s 2/2 t 3/3 1/1 3/1 21

Algorithm 2/1 1/1 4/1 2/1 1/1 4/1 s 2/0 t s 2/0 t 3/0 1/0 3/0 3/1 1/1 3/1 2/1 1/1 4/3 1 1 1 s 2/2 t s 2 1 t 3/3 1/1 3/1 3 1 2 22

Another Example C C s 1 C C Require O(n 3 C) time in the worst case! 23

Improvements The shortest-path heuristic can reduce the time to O(n 5 ). 24

Bipartite Matching A bipartite graph is a triple B = (U, V, E) where U = {u 1,...,u n }, V = {v 1,...,v n }, and E U V. 25

Matching A matching of a bipartite graph B is a set M E s.t. 1. M = n; 2. for any two edges (u, v), (u, v ) M, u u and v v. 26

Algorithm Reduce MATCHING to MAX FLOW. 27

Traveling Salesman Problem Given n cities 1, 2,...,n and a nonnegative integer distance d i,j between any two cities i and j, find the shortest tour n i=1 d π(i),π(j) where π is a permutation on {1,...,n}. 28

Example 10 5 1 11 8 3 4 5 6 16 4 5 20 2 8 2 29

Remark TSP is NP-hard (its decision version is in fact NP-complete). There is no known polynomial-time algorithm for solving TSP. If a problem is NP-complete, most computer scientists believe that there is no polynomial-time algorithm for it. 30

We have discussed 1. Graph Reachability 2. Big-O notation 3. Maximum Flow 4. Bipartite Matching Summary 5. Traveling Salesman Problem 31

MAX FLOW = REACHABILITY. MATCHING = MAX FLOW. They are all polynomial-time solvable. However, we don t know whether there exists a polynomial-time algorithm that can solve TSP. 32

Reduction Reduction is a classical technique, which transforms an unknown problem to an existing one. It usually implies to transform a harder problem into an easier one. However, in complexity theory, we use it in the perverse way. When A reduces to B, we say that B can not be easier that A. ( Vreduce VÃø ) 33

Big-O Big-O captures the asymptotic behavior for comparison of two positive functions. However, why we ignore the constant coefficient? 34

Problem 1.4.4 (a) A directed graph is acyclic if it has no cycles. Show that any acyclic graph has a source (a node with no incoming edges). (b) Show that a graph with n nodes is acyclic if and only if its nodes can be numbered 1 to n so that all edges go from lower to higher numbers (use the property in (a) above repeatedly). (c) Describe a polynomial-time algorithm that decides whether a graph is acyclic. 35

Problem 1.4.5 (a) Show that a graph is bipartite (that is, its nodes can be partitioned into two sets, not necessarily of equal cardinality, with edges going only from one to the other) if and only if it has no odd-length cycles. (b) Describe a polynomial algorithm for testing whether a graph is bipartite. 36

Problem 1.4.9 Show that for any polynomial p(n) and any constant c > 0 there is an integer n 0 such that, for all n n 0, 2 cn > p(n). Calculate this n 0 when (a) p(n) = n 2 and c = 1; (b) when p(n) = 100n 100 and c = 1 100. 37