Time Complexity. CS60001: Foundations of Computing Science

Similar documents
Chapter 7: Time Complexity

Theory of Computation Time Complexity

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) Spring l. Blum TIME COMPLEXITY AND POLYNOMIAL TIME;

CSE 105 THEORY OF COMPUTATION

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CS154, Lecture 13: P vs NP

Theory of Computation

TIME COMPLEXITY AND POLYNOMIAL TIME; NON DETERMINISTIC TURING MACHINES AND NP. THURSDAY Mar 20

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

CSE 135: Introduction to Theory of Computation NP-completeness

CS154, Lecture 13: P vs NP

CSE 105 Theory of Computation

Lecture 16: Time Complexity and P vs NP

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

Computability Theory

CISC 4090 Theory of Computation

Lecture 19: Finish NP-Completeness, conp and Friends

P and NP. Or, how to make $1,000,000.

Complexity (Pre Lecture)

Computational complexity

Could we potentially place A in a smaller complexity class if we consider other computational models?

1 Non-deterministic Turing Machine

Finish K-Complexity, Start Time Complexity

BBM402-Lecture 11: The Class NP

22c:135 Theory of Computation. Analyzing an Algorithm. Simplifying Conventions. Example computation. How much time does M1 take to decide A?

CS154, Lecture 17: conp, Oracles again, Space Complexity

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computational Complexity

Computability and Complexity

Theory of Computation CS3102 Spring 2015 A tale of computers, math, problem solving, life, love and tragic death

Computational Models Lecture 11, Spring 2009

conp, Oracles, Space Complexity

Definition: conp = { L L NP } What does a conp computation look like?

Polynomial time reduction and NP-completeness. Exploring some time complexity limits of polynomial time algorithmic solutions

P vs. NP Classes. Prof. (Dr.) K.R. Chowdhary.

Complexity: moving from qualitative to quantitative considerations

1 Computational Problems

Harvard CS 121 and CSCI E-121 Lecture 20: Polynomial Time

Computer Sciences Department

Notes for Lecture Notes 2

Intro to Theory of Computation

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

Lecture 21: Space Complexity (The Final Exam Frontier?)

Chapter 2 : Time complexity

Advanced Topics in Theoretical Computer Science

q FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) Spring L. Blum. REVIEW for Midterm 2 TURING MACHINE

Introduction to Complexity Theory

Intractable Problems [HMU06,Chp.10a]

Intro to Theory of Computation

Lecture 17: Cook-Levin Theorem, NP-Complete Problems

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan August 30, Notes for Lecture 1

Lecture 3: Nondeterminism, NP, and NP-completeness

Intro to Theory of Computation

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

Computability and Complexity

Theory of Computation

Computability Theory

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

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

COMPLEXITY THEORY. PSPACE = SPACE(n k ) k N. NPSPACE = NSPACE(n k ) 10/30/2012. Space Complexity: Savitch's Theorem and PSPACE- Completeness

CP405 Theory of Computation

Time Complexity. Definition. Let t : n n be a function. NTIME(t(n)) = {L L is a language decidable by a O(t(n)) deterministic TM}

NP-Completeness. A language B is NP-complete iff B NP. This property means B is NP hard

The space complexity of a standard Turing machine. The space complexity of a nondeterministic Turing machine

Time-Space Tradeoffs for SAT

CS294: Pseudorandomness and Combinatorial Constructions September 13, Notes for Lecture 5

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

INTRODUCTION TO THE THEORY OF NP-COMPLETENESS

Agenda. What is a complexity class? What are the important complexity classes? How do you prove an algorithm is in a certain class

Lecture 18: PCP Theorem and Hardness of Approximation I

The Complexity of Optimization Problems

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

Welcome to... Problem Analysis and Complexity Theory , 3 VU

The Cook-Levin Theorem

Complexity Theory Part I

Intractable Problems. Time-Bounded Turing Machines Classes P and NP Polynomial-Time Reductions

The Polynomial Hierarchy

Correctness of Dijkstra s algorithm

CSC 1700 Analysis of Algorithms: P and NP Problems

Computability and Complexity CISC462, Fall 2018, Space complexity 1

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

Complexity, P and NP

CS6901: review of Theory of Computation and Algorithms

NP Complete Problems. COMP 215 Lecture 20

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

Turing Machines and Time Complexity

Limits of Feasibility. Example. Complexity Relationships among Models. 1. Complexity Relationships among Models

P, NP, NP-Complete, and NPhard

Review of unsolvability

NP-Complete Problems. More reductions

Asymptotic notation : big-o and small-o

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

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

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

Time to learn about NP-completeness!

Transcription:

Time Complexity CS60001: Foundations of Computing Science Professor, Dept. of Computer Sc. & Engg.,

Measuring Complexity Definition Let M be a deterministic Turing machine that halts on all inputs. The running time or time complexity of M is the function f: N N, where f(n) is the running time of M, we say that M runs in time f(n) and that M is an f(n) time Turing machine. Customarily we use n to represent the length of the input Complexity Analysis Worst-case Analysis Longest running time of all inputs of a particular length Average-case Analysis Average of all the running times of inputs of a particular length 2

Big-O and Small-o Notations Asymptotic Upper Bound (O) Let f and g be functions f, g: N R +. Say that f(n) = O(g(n)) if positive integers c and n 0 exist such that for every integer n n 0 f(n) c.g(n) When f(n) = O(g(n)) we say that g(n) is an upper bound for f(n), or more precisely, that g(n) is an asymptotic upper bound for f(n), to emphasize that we are suppressing constant factors Asymptotic Strict-Upper Bound (o) Let f and g be functions f, g: N R +. Say that f(n) = o(g(n)) if f(n) lim = 0 g(n) n 8 In other words, f(n) = o(g(n)) means that, for any real number c > 0, a number n 0 exist, where f(n) < c.g(n) for all n n 0 3

Analyzing Algorithms Let t: N R + be a function. Define the time complexity class, TIME(t(n)), to be the collection of all languages that are decidable by an O(t(n)) time Turing machine Example Analyze the TM algorithm for the language A = {0 k 1 k k 0} There can be different TM constructions (M 1, M 2, M 3 ) deciding the language [see Sipser s Book, pp. 207-209] The total-time taken by them is different M 1 decides A in time O(n 2 ), therefore A TIME(n 2 ) M 2 decides A in time O(nlogn), therefore A TIME(n.logn) M 3 decides A in time O(n), therefore A TIME(n) 4

Complexity Relationships among Models Definition Let N TM be a non-deterministic Turing machine that is a decider. The running time of N TM is the function f: N N, where f(n) is the maximum number of steps that N TM uses on any branch of its computation on any input n Theorems Let t(n) be a function, where t(n) n. Then every t(n) time multi-tape Turing machine has an equivalent O(t 2 (n)) time single-tape Turing machine Let t(n) be a function, where t(n) n. Then every t(n) time non-deterministic single-tape Turing machine has an equivalent 2 O(t(n)) time deterministic single-tape Turing machine 5

The Class P (Polynomial Time) Definition P is the class of languages that are decidable in polynomial time on a deterministic single-tape Turing machine. In other words, The role of P in theory: P = U TIME(n k ) P is invariant for all models of computation that are polynomially equivalent to the deterministic single-tape Turing machine P roughly corresponds to the class of problems that are realistically solvable on a computer Examples of Problems in P PATH = {<G, s, t> G is a directed graph that has a directed path from s to t} RELATIVE_PRIME = {<x, y> x and y are relatively prime} Every context-free language is a member of P k 6

The Class NP (Non-deterministic Polynomial Time) Definitions A verifier for a language A is an algorithm V, where A = {w V accepts <w, c> for some string c}. We measure the time of a verifier only in terms of the length of w, so a polynomial time verifier runs in polynomial time in the length of w. A language A is polynomially verifiable if it has a polynomial time verifier. NP is the class of languages that have polynomial time verifiers UI Examples of Problems in NP HAM_PATH = {<G, s, t> G is a directed graph with a Hamiltonian path from s to t} COMPOSITES = {x x = pq, for integers p, q > 1} CLIQUE = {<G, k> G is an undirected graph with k-clique} SUBSET-SUM = {<S, t> S = {x1, x2,, xk} and for some {y1, y2,, yl} {x1, x2,, xk}, we have Σyi = t} 7

The Class NP (contd ) Theorem A language is in NP if and only if it is decided by some non-deterministic polynomial time Turing machine Definition Non-deterministic time complexity class is defined as, NTIME(t(n)) = {L L is a language decided by a O(t(n)) time non-deterministic Turing machine} Corollary: NP = U NTIME(n k ) k 8

The P Versus NP Question Referring (loosely) to polynomial time solvable as solvable quickly, P = the class of languages for which membership can be decided quickly NP = the class of languages for which membership can be verified quickly Unsolved Problem in Theoretical Computer Science P = NP? OR P NP? One of these two possibilities is correct P NP P = NP Best method known for solving languages in NP deterministically uses exponential time. In other words, we can prove that NP EXPTIME = U TIME(2 n ) But, we do not know whether NP is contained in a smaller deterministic time complexity class UI k k 9

NP-Completeness Polynomial Time Reducibility A function f: Σ* Σ* is a polynomial time computable function if some polynomial time Turing machine M exists that halts with just f(w) on its tape, when started on any input w Language A is polynomial time mapping reducible, or simply polynomial time reducible, to language B, written A p B, if a polynomial time computable function f: Σ* Σ* exists, where for every w, w A f(w) B The function f is called the polynomial time reduction of A to B Theorem If A p B and B P, then A P 3SAT is polynomial time reducible to CLIQUE 10

NP-Completeness (contd...) Definition A language B is NP-complete if it satisfies two conditions: B is in NP, and Every A in NP is polynomial time reducible to B Theorems If B is NP-complete and B P, then P = NP If B is NP-complete and B p C for C in NP, then C is NP-complete COOK-LEVIN s Theorem SAT is NP-complete (other form: SAT P if and only if P = NP) Corollary: 3SAT is NP-complete 11

Additional NP-Complete Problems Examples of NP-complete Problems CLIQUE = {<G, k> G is an undirected graph with k-clique} VERTEX-COVER = {<G, k> G is an undirected graph that has a k-node vertex cover} HAM_PATH = {<G, s, t> G is a directed graph with a Hamiltonian path from s to t} UHAM_PATH = Hamiltonian path in undirected graph SUBSET-SUM = {<S, t> S = {x 1, x 2,, x k } and for some {y 1, y 2,, y l } {x 1, x 2,, x k }, we have Σy i = t} UI 12