CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT 20077.1 Lecture 8+9 Time complexity 1 Jan Maluszynski, IDA, 2007

Slides:



Advertisements
Similar presentations
Measuring Time Complexity
Advertisements

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSE 373: Data Structures and Algorithms Lecture 5: Math Review/Asymptotic Analysis III 1.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
The diagonalization method The halting problem is undecidable Decidability.
Measuring Time Complexity Sipser 7.1 (pages )
P and NP Sipser (pages ). CS 311 Fall Polynomial time P = ∪ k TIME(n k ) … P = ∪ k TIME(n k ) … TIME(n 3 ) TIME(n 2 ) TIME(n)
Complexity ©D.Moshkovitz 1 Turing Machines. Complexity ©D.Moshkovitz 2 Motivation Our main goal in this course is to analyze problems and categorize them.
TDDB56 DALGOPT-D TDDB57 DALG-C Lecture 2 Jan Maluszynski - HT TDDB56 – DALGOPT-D Algorithms and optimization TDDB57 – DALG-C Data Structures and.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
Lecture 5 Turing Machines
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 1 Introduction Jan Maluszynski, IDA, 2007
Cmpt-225 Algorithm Efficiency.
CSE 830: Design and Theory of Algorithms Dr. Eric Torng.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 6 Decidability Jan Maluszynski, IDA, 2007
CS 310 – Fall 2006 Pacific University CS310 P vs NP the steel cage death match Section 7.2 November 29, 2006.
Asymptotic Analysis Motivation Definitions Common complexity functions
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 2 Elements of complexity analysis Performance and efficiency Motivation: analysis.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
TTIT33 Algorithms and Optimization – Lecture 1 Jan Maluszynski - HT Analysis of Algorithms Introductory Example Principles of Analysis Big-Oh notation.
CS 310 – Fall 2006 Pacific University CS310 Complexity Section 7.1 November 27, 2006.
Analysis of Algorithms COMP171 Fall Analysis of Algorithms / Slide 2 Introduction * What is Algorithm? n a clearly specified set of simple instructions.
Algorithm Analysis (Big O)
Analysis of Performance
CS 461 – Nov. 21 Sections 7.1 – 7.2 Measuring complexity Dividing decidable languages into complexity classes. Algorithm complexity depends on what kind.
Mathematics Review and Asymptotic Notation
Analysis of Algorithms
Analysis of Algorithm Efficiency Dr. Yingwu Zhu p5-11, p16-29, p43-53, p93-96.
Asymptotic Analysis-Ch. 3
Complexity A decidable problem is computationally solvable. But what resources are needed to solve the problem? –How much time will it require? –How much.
Algorithms Growth of Functions. Some Notation NNatural numbers RReal numbers N + Positive natural numbers R + Positive real numbers R * Non-negative real.
Introduction to Programming (in C++) Complexity Analysis of Algorithms
Measuring complexity Section 7.1 Giorgi Japaridze Theory of Computability.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
CSC – 332 Data Structures Generics Analysis of Algorithms Dr. Curry Guinn.
Introduction to Analysis of Algorithms CS342 S2004.
Time Complexity of Algorithms
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 7 Undecidability cont. Jan Maluszynski, IDA, 2007
David Luebke 1 1/6/2016 CS 332: Algorithms Asymptotic Performance.
1/6/20161 CS 3343: Analysis of Algorithms Lecture 2: Asymptotic Notations.
CS 461 – Nov. 18 Section 7.1 Overview of complexity issues –“Can quickly decide” vs. “Can quickly verify” Measuring complexity Dividing decidable languages.
A Introduction to Computing II Lecture 5: Complexity of Algorithms Fall Session 2000.
LECTURE 2 : fundamentals of analysis of algorithm efficiency Introduction to design and analysis algorithm 1.
Theory of Computational Complexity TA : Junichi Teruyama Iwama lab. D3
CSCI 2670 Introduction to Theory of Computing November 15, 2005.
Lecture 3COMPSCI.220.S1.T Running Time: Estimation Rules Running time is proportional to the most significant term in T(n) Once a problem size.
 2005 SDU Lecture14 Mapping Reducibility, Complexity.
CSE 105 theory of computation
CSCI 2670 Introduction to Theory of Computing
Time complexity Here we will consider elements of computational complexity theory – an investigation of the time (or other resources) required for solving.
Complexity & the O-Notation
Introduction to the Analysis of Complexity
CSCI 2670 Introduction to Theory of Computing
Time Complexity Analysis Neil Tang 01/19/2010
Algorithm Analysis Neil Tang 01/22/2008
Intro to Theory of Computation
Chapter 14 Time Complexity.
Chapter 2.
CS21 Decidability and Tractability
Theory of Computability
CS154, Lecture 12: Time Complexity
CSC 4170 Theory of Computation Time complexity Section 7.1.
CS21 Decidability and Tractability
CSC 380: Design and Analysis of Algorithms
At the end of this session, learner will be able to:
Theory of Computability
CSCI 2670 Introduction to Theory of Computing
CSE 105 theory of computation
CSC 4170 Theory of Computation Time complexity Section 7.1.
Intro to Theory of Computation
Presentation transcript:

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 8+9 Time complexity 1 Jan Maluszynski, IDA,

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Outline Time Complexity 1 (Sipser 7.1 – 7.2) 1.Motivation 2.Big Oh notation 3.Complexity classes TIME(t(n)) and P 4.Relations between various models of algorithms 5.Analysis of example algorithms

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Motivation We want to compare efficiency of algorithms Algorithm : Turing Machine Efficiency: number of steps to accept an input. Other models should also be considered: RAM with pseudocode Real programming languages

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Principles of Algorithm Analysis An algorithm works for input of any size. Show the resource (time/memory) used as an increasing function of input size. Focus on the worst case performance. Ignore constant factors analysis should be machine-independent; more powerful computers introduce speed-up by constant factors. Study scalability / asymptotic behaviour for large problem sizes: ignore lower-order terms, focus on dominating terms.

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Use asymptotic analysis! Consider two growing functions f, g from natural numbers to positive real numbers: f dominates g iff f(n) / g(n) increases without bounds for n   that is, for a given constant factor c > 0, there is some threshold value such that

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Types of growth comparison: f, g growing functions from natural numbers to positive real numbers f is (in) O ( g) iff there exist c > 0, n 0  1 such that f(n )  c g(n) for all n  n 0 Intuition: Apart from constant factors, f grows at most as quickly as g f is (in)  ( g ) iff there exist c > 0, n 0  1 such that f ( n)  c g(n) for all n  n 0 Intuition: Apart from constant factors, f grows at least as quickly as g  is the converse of O, i.e. f is in  (g) iff g is in O(f)  f is (in)  (g) iff f(n)  O(g(n)) and g(n)  O(f(n)) Intuition: Apart from constant factors, f grows exactly as quickly as g

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Types of growth comparison:  (g),  (g), O ( g)..??

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT …comparison with simple math function: 1.84* µ sec = 2.14 * 10 8 days = 5845 centuries nlog 2 nnn log 2 nn2n2 2n2n * * 10 19

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Asymptotic analysis: Dominance Relation Revisited Growing functions on natural numbers: f and g there exists f is (in) o ( g) iff there exist c > 0, n 0  1 such that f(n )  c g(n) for all n  n 0 for any c f(n ) < g(n) i.e., f is dominated by g Intuition: g grows strictly more quickly than f. If f  o(g) then f O(g) but not vice versa. Example: n  o(2 n )

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Time complexity classes t: N  R + TIME(t(n)) : collection of all languages decidable by an O(t(n)) single tape deterministic TM P: collection of all languages decidable in polynomial time by single tape deterministic TM

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Example A = {0 k 1 k |k  0} On input string w: M1: 1.Scan the tape reject if 0 found to the right of 1 2.Repeat if both 0 and 1 are on tape: Scan crossing off single 0 and single 1 3. If there are still some 0’s or some 1’s reject otherwise accept M1 is O(n 2 ); A is in TIME (n 2 );

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Example A = {0 k 1 k |k  0} On input string w: M2: 1.Scan the tape reject if 0 found to the right of 1 2.Repeat if both 0 and 1 are on tape: Scan if total number of 1’s and 0’s is odd reject Scan crossing off every second 0 and every second 1 3. If there are still some 0’s or some 1’s reject otherwise accept M1 is O(n log n); A is in TIME (n log n);

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Relations between models t: N  R + t(n)  n Every t(n) time multitape Turing machine has an equivalent O(t 2 (n)) single-tape Turing machine. Every t(n) time nondeterministic Turing machine decider has an equivalent 2 +O(t(n)) deterministic single-tape Turing machine. All deterministic computational models are polynomially equivalent.

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Examples of problems in P PATH: is there a path from s to t in a graph G? RELPRIME: are natural numbers x and y relatively prime ? CFG parsing: is a string x derivable in a CFG G Searching: is a string x in a set S ? ….

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Estimating execution time for iterative programs

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Analysis of algorithms in pseudocode What is the worst-case problem instance? What is the worst case time? What is the ”complexity” for this function?

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Example: Dependent Nested Loops

CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Analysis of Recursive Program (1)