CSCI 2670 Introduction to Theory of Computing

Slides:



Advertisements
Similar presentations
Razdan with contribution from others 1 Algorithm Analysis What is the Big ‘O Bout? Anshuman Razdan Div of Computing.
Advertisements

The Growth of Functions
CS 310 – Fall 2006 Pacific University CS310 Complexity Section 7.1 November 27, 2006.
Instructor Neelima Gupta
CSCI 2670 Introduction to Theory of Computing November 10, 2005.
Algorithm Efficiency CS 110: Data Structures and Algorithms First Semester,
Mathematics Review and Asymptotic Notation
CSC 201 Analysis and Design of Algorithms Lecture 04: CSC 201 Analysis and Design of Algorithms Lecture 04: Time complexity analysis in form of Big-Oh.
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.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
Measuring complexity Section 7.1 Giorgi Japaridze Theory of Computability.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Time Complexity. Solving a computational program Describing the general steps of the solution –Algorithm’s course Use abstract data types and pseudo code.
David Luebke 1 1/6/2016 CS 332: Algorithms Asymptotic Performance.
Algorithm Analysis (Big O)
Computability Sort homework. Formal definitions of time complexity. Big 0. Homework: Exercises. Searching. Shuffling.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong
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.
Analysis of Algorithms Algorithm Input Output © 2014 Goodrich, Tamassia, Goldwasser1Analysis of Algorithms Presentation for use with the textbook Data.
Data Structures I (CPCS-204) Week # 2: Algorithm Analysis tools Dr. Omar Batarfi Dr. Yahya Dahab Dr. Imtiaz Khan.
Analysis of Algorithms
CSCI 2670 Introduction to Theory of Computing
COMP9024: Data Structures and Algorithms
Analysis of Algorithms
GC 211:Data Structures Week 2: Algorithm Analysis Tools
COMP108 Algorithmic Foundations Algorithm efficiency
Time complexity Here we will consider elements of computational complexity theory – an investigation of the time (or other resources) required for solving.
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Introduction to Algorithms
Assignment 2 Tze calculations.
Analysis of Algorithms
COMP9024: Data Structures and Algorithms
The Growth of Functions
Analysis of Algorithms
CS 3343: Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Asymptotic Notations Algorithms Lecture 9.
CSC 413/513: Intro to Algorithms
Analysis of Algorithms
Introduction to Algorithms Analysis
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Asymptotic Growth Rate
CSI Growth of Functions
Analysis of Algorithms
Chapter 2: Fundamentals of the Analysis of Algorithm Efficiency
CS 3343: Analysis of Algorithms
Analysis of Algorithms
Analysys & Complexity of Algorithms
Advanced Analysis of Algorithms
Analysis of Algorithms
CSE 373, Copyright S. Tanimoto, 2002 Asymptotic Analysis -
Complexity Analysis Text is mainly from Chapter 2 by Drozdek.
CSC 4170 Theory of Computation Time complexity Section 7.1.
Algorithms Analysis Algorithm efficiency can be measured in terms of:
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007
Discrete Mathematics 7th edition, 2009
Design and Analysis of Algorithms
Theory of Computability
CSE 373, Copyright S. Tanimoto, 2001 Asymptotic Analysis -
CSCI 2670 Introduction to Theory of Computing
CSC 4170 Theory of Computation Time complexity Section 7.1.
Analysis of Algorithms
Intro to Theory of Computation
Presentation transcript:

CSCI 2670 Introduction to Theory of Computing November 9, 2005

Agenda Yesterday Today Remainder of semester Review of undecidability proofs Today Section 7.1 Remainder of semester Chapter 7 November 9, 2005

Complexity of algorithms Among decidable problems, we still have levels of difficulty for algorithms We may consider an algorithm more difficult for a variety of reasons Takes longer to execute Requires more memory to execute Time complexity: Given an algorithm and an input string, how long will the algorithm take to execute? November 9, 2005

Example INSERTION-SORT(A) For j = 2 to length(A) key := A[j] i := j-1 While i > 0 and A[i] > key A[i+1] := A[i] i := i-1 A[i+1] := key November 9, 2005

Trace 4 6 1 8 5 3 Start by looking at 6 & compare to 4 6  4 Next look at 1 1 4 6 8 5 3 8 is okay Move 5 then move 3 1 4 5 6 8 3 1 3 4 5 6 8 November 9, 2005

How long does insertion sort take? Two loops Outer loop executed (n-1) times n = length(A) Inner loop executed up to j times Total time is at most 1‹k<n (4+1i<k 3) 1‹k<n 4+ 1‹k<n 3k 4(n-1) + 3[(n+1)n/2-1] = 4n- 4 + 1.5 n2 + 1.5 n – 2 = 1.5 n2 + 5.5 n - 6 November 9, 2005

Time complexity Definition: Let M be any 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 maximum number of steps that M uses on any input of length n. November 9, 2005

Big-O notation In general, the time complexity will be the sum of terms that is dominated by one term E.g., n2 + 2n – 3 is dominated by the n2 term Time complexity is most concerned with behavior for large n We disregard all terms except for the dominating term n2 +2n -3 = O(n2) November 9, 2005

Asymptotic upper bound Definition: Let f and g be two functions from N to R+ (the set of positive real numbers). Then f(n)=O(g(n)) if positive integers c and n0 exist such that for every n ≥ n0, f(n) ≤ c × g(n). In this case, we say that g(n) is an upper bound for f(n) November 9, 2005

Example 3n4 + 5n2 – 4 = O(n4) 3n4 + 5n2 – 4  4n4 for every n  2 since 3n4 + 5n2 – 4  4n4  n4 - 5n2 + 4  0  (n2-4)(n2-1)  0 clearly holds for all n  2 For polynomials, we can drop everything except nk, where k is the largest exponent November 9, 2005

Big-O notation and logarithms Recall logbn = logxn / logxb logbn = O(logxn) for every x > 0 With big-O notation, the base of the logarithm is unimportant! 5n5 log3n – 3n2log2log2n = O(n5 log n) November 9, 2005

Mathematics with big-O notation If f(n) = O(n3) + O(n), then f(n) = O(n3) Can simply select the largest term What does f(n) = 3O(n) mean? 3O(n)  3cn for some constant c How about O(1)? O(1)  c for some constant c Constant time November 9, 2005

Exponential time What about f(n) = 2O(log n)? n = 2log_2 n  nc = 2O(log n)  2O(log n) = nO(1) An algorithm takes exponential time if its complexity is O(an^k), where k>0 An algorithm takes polynomial time if its complexity is O(nk) for some k > 0 November 9, 2005

Small-o notation Definition: Let f and g be two functions from N to R+ (the set of positive real numbers). Then f(n)=o(g(n)) limn→(f(n)/g(n)) = 0 i.e., for any positive real number c, a number n0 exists such that for every n  n0, f(n) < c × g(n) November 9, 2005

Big-O versus small-o If f(n) = o(g(n)) then f(n) = O(g(n)), but the reverse is not always true Big-O is like “less than or equal” while small-o is like “strictly less than” Example f(n) = O(f(n)) for every function f f(n) ≠ o(f(n)) for every function f November 9, 2005

Some identities ni = o(nk) for every i < k log n = o(n) log log n = o(log n) November 9, 2005