Lecture 44 Section 9.2 Mon, Apr 23, 2007

Slides:



Advertisements
Similar presentations
CMSC 341 Asymptotic Analysis. 2 Mileage Example Problem: John drives his car, how much gas does he use?
Advertisements

 The running time of an algorithm as input size approaches infinity is called the asymptotic running time  We study different notations for asymptotic.
Week 12 - Monday.  What did we talk about last time?  Trees  Graphing functions.
Discrete Mathematics CS 2610 February 26, part 1.
The Growth of Functions
Asymptotic Growth Rate
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
Real-Valued Functions of a Real Variable and Their Graphs
Data Structures and Algorithms1 Basics -- 2 From: Data Structures and Their Algorithms, by Harry R. Lewis and Larry Denenberg (Harvard University: Harper.
Analysis of Algorithms CPS212 Gordon College. Measuring the efficiency of algorithms There are 2 algorithms: algo1 and algo2 that produce the same results.
1 i206: Lecture 6: Math Review, Begin Analysis of Algorithms Marti Hearst Spring 2012.
Real-Valued Functions of a Real Variable and Their Graphs Lecture 43 Section 9.1 Wed, Apr 18, 2007.
1 Growth of Functions CS 202 Epp, section ??? Aaron Bloomfield.
DISCRETE MATHEMATICS I CHAPTER 11 Dr. Adam Anthony Spring 2011 Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco.
Real-Valued Functions of a Real Variable and Their Graphs Lecture 38 Section 9.1 Mon, Mar 28, 2005.
CMSC 341 Asymptotic Analysis. 2 Complexity How many resources will it take to solve a problem of a given size? –time –space Expressed as a function of.
Week 12 - Wednesday.  What did we talk about last time?  Asymptotic notation.
O, , and  Notations Lecture 39 Section 9.2 Wed, Mar 30, 2005.
Week 11 - Friday.  What did we talk about last time?  Graph isomorphism  Trees.
CompSci 102 Discrete Math for Computer Science
Slide Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
O -Notation April 23, 2003 Prepared by Doug Hogan CSE 260.
CMSC 341 Asymptotic Analysis. 2 Complexity How many resources will it take to solve a problem of a given size? –time –space Expressed as a function of.
Asymptotic Analysis (based on slides used at UMBC)
Big Oh Notation Greek letter Omicron (Ο) is used to denote the limit of asymptotic growth of an algorithm If algorithm processing time grows linearly with.
The Fundamentals. Algorithms What is an algorithm? An algorithm is “a finite set of precise instructions for performing a computation or for solving.
Equivalence Relations Lecture 45 Section 10.3 Fri, Apr 8, 2005.
Partial Order Relations Lecture 50 Section 10.5 Wed, Apr 20, 2005.
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
Jessie Zhao Course page: 1.
Equivalence Relations
Algorithms Chapter 3.
College Algebra Chapter 3 Polynomial and Rational Functions
Calculus I Hughes-Hallett
The Growth of Functions
Relative Rates of Growth
Partial Order Relations
The Growth of Functions
General Logarithmic and Exponential Functions
Enough Mathematical Appetizers!
4.4 Real Zeros of Polynomial Functions
Computation.
CS 2210 Discrete Structures Algorithms and Complexity
Asymptotics & Stirling’s Approximation
Asymptotic Growth Rate
CMSC 341 Asymptotic Analysis.
Orders of Growth Rosen 5th ed., §2.2.
CS 2210 Discrete Structures Algorithms and Complexity
Advanced Analysis of Algorithms
GC 211:Data Structures Algorithm Analysis Tools
Lesson 2.3 Real Zeros of Polynomial Functions
Lecture 43 Section 10.1 Wed, Apr 6, 2005
Time Complexity Lecture 14 Sec 10.4 Thu, Feb 22, 2007.
Composition of Functions
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Enough Mathematical Appetizers!
Intro to Data Structures
Asymptotics & Stirling’s Approximation
Time Complexity Lecture 15 Mon, Feb 27, 2006.
Miniconference on the Mathematics of Computation
Combinations and Pascal’s triangle
Asymptotics & Stirling’s Approximation
Enough Mathematical Appetizers!
College Algebra Chapter 3 Polynomial and Rational Functions
Algorithms Chapter 3 With Question/Answer Animations.
Advanced Analysis of Algorithms
Equivalence Relations
Algorithm Course Dr. Aref Rashad
CS 2210 Discrete Structures Algorithms and Complexity
Presentation transcript:

Lecture 44 Section 9.2 Mon, Apr 23, 2007 O, , and  Notations Lecture 44 Section 9.2 Mon, Apr 23, 2007

 Notation Let g : R  R be a function. A function f : R  R is of order at least g, written f(x) is(g(x)), if there exist real numbers M, x0 such that f(x)  Mg(x) for all x  x0.

“Big-Oh” Notation A function f : R  R is of order at most g, written f(x) isO(g(x)), if there exist real numbers M, x0 such that f(x)  Mg(x) for all x  x0.

M1g(x)  f(x)  M2g(x)  Notation A function f : R  R is of order g, written f(x) is(g(x)), if there exist real numbers M1, M2, x0  R such that M1g(x)  f(x)  M2g(x) for all x  x0.

Growth Rates If f(x) is O(g(x)), then the growth rate of f is no greater than the growth rate of g, and maybe less. If f(x) is (g(x)), then the growth rate of f is no less than the growth rate of g, and maybe greater.

Growth Rates Theorem: If f(x) is O(g(x)) and g(x) is O(f(x)), then f(x) is (g(x)). Proof: If f(x) is O(g(x)), then there exist M1, x1  R such that f(x)  M1g(x) for all x  x1. If g(x) is O(f(x)), then there exist M2, x2  R such that g(x)  M2f(x) for all x  x2.

(1/M2)g(x)  f(x)  M1g(x) Growth Rates Let x3 = max(x1, x2). Then (1/M2)g(x)  f(x)  M1g(x) for all x  x3. Therefore, f(x) is (g(x)). We call (f(x)) the growth rate of f.

Growth Rates Theorem: f(x) is (g(x)) if and only if f(x) is (g(x)) and f(x) is O(g(x)). Proof: Show that if f(x) is (g(x)), then g(x) is O(f(x)). Then apply the previous theorem.

Common Growth Rates Growth Rate Example (1) Access an array element (log2 x) Binary search (x) Sequential search (x log2 x) Quick sort (x2) Bubble sort (2x) Factor an integer (x!) Traveling salesman problem

Transitivity of O(f) Theorem: Let f, g, and h be functions from R to R. If f(x) is O(g(x)) and g(x) is O(h(x)), then f(x) is O(h(x)). Proof: If f(x) is O(g(x)), then f(x)  M1g(x) for all x  x1, for some M1 and x1. If g(x) is O(h(x)), then g(x)  M2h(x) for all x  x2, for some M2 and x2.

Transitivity of O(f) Let x3 = max(x1, x2). Then f(x)  M1M2h(x), for all x  x3. Therefore, f(x) is O(h(x)).

Power Functions Theorem: If 0  a  b, then xa is O(xb), but xb is not O(xa). Proof: Since a  b, for all x > 1, xa – b < 1. Therefore, xa < xb for all x > 1. On the other hand, suppose xb  Mxa, for some M and for all x > x0, for some x0.

Power Functions Then, xb – a  M, for all x > x0. But b – a > 0, so xb – a increases without bound. This is a contradiction, so xb is not O(xa).

Application Any polynomial of degree d is For example, O(xn), if d < n. (xn), if n = d. (xn), if d > n. For example, 16x3 – 10x2 + 3x – 12 is (x2), (x3), and O(x4).

Helpful Facts from Calculus Theorem: If then f(x) is (g(x)).

Helpful Facts from Calculus Theorem: If then f(x) is O(g(x)).

Helpful Facts from Calculus Theorem: If then f(x) is (g(x)).

L’Hôpital’s Rule Theorem: If and then

Logarithmic Functions Lemma: Theorem: For all a, b  1, loga x is (logb x). Proof:

Application Since all logarithmic functions are of the same order, it doesn’t matter which base we use.

Logarithmic Functions vs. Power Functions Theorem: For all a > 1, b > 0, loga x is O(xb), but xb is not O(loga x). Proof:

Application Every polynomial function has a faster growth rate than all logarithmic functions. If a function mixes polynomial terms and logarithmic terms, then the polynomial terms “dominate.” For example, 3x2 + 20 log10 (5x + 2) is (x2).

Exponential Functions Theorem: If 1 < a < b, then ax is O(bx), but bx is not O(ax). Proof: It is clear that

Application Any exponential function with base a is (bx), if b < a. (bx), if b = a. O(bx), if b > a. For example, 5(8x) is (2x), (8x), and O(10x). How does 2x compare to 21.1x?

Power Functions vs. Exponential Functions Theorem: For all a > 0, b > 1, xa is O(bx), but bx is not O(xa).

Application If a function is a mix of polynomial terms, logarithmic terms, and exponential terms, the exponential term with the highest base “dominates.” For example, 5x3 + 2 log2 x + 100(3x) + 28(5x) is (5x).

Benefits of O, , and  Clearly, the -notation is useful because it singles out the term that best represents the growth rate of the function (for large x). The O-notation is useful when we can’t pin down the exact growth rate, but we can put an upper bound on it. Similarly, the -notation expresses a lower bound.

Multiplicativity of O(f) Theorem: Let f, g, h, and k be functions from R to R. If f(x) is O(h(x)) and g(x) is O(k(x)), then f(x)g(x) is O(h(x)k(x)). Proof: Suppose f(x)  M1h(x) for all x  x1 and g(x)  M2k(x) for all x  x2, for some M1, M2, x1, x2. Then f(x)g(x)  M1 M2h(x)k(x) for all x  max(x1, x2).

Application We know that log x is O(x) and that x is O(x), so x log x is O(x2). More generally, xd is O(xd log x). xd log x is O(xd + 1).