Algorithms and Discrete Mathematics 20082009 - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Algorithms and Discrete Mathematics 20082009

Description:

The Big-O notation. The definition says that after a certain point, namely after k, the ... Big-O of polynomials. We have. With witnesses ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 12
Provided by: dur9
Category:

less

Transcript and Presenter's Notes

Title: Algorithms and Discrete Mathematics 20082009


1
Algorithms and Discrete Mathematics 2008/2009
  • Lecture 7
  • Big-O notation

Ioannis Ivrissimtzis
24-Nov-2008
2
Overview of the lecture
  • The Big-O notation

3
The Big-O notation
  • Let f and g be functions from the set of integers
    or the set of real
  • numbers to the set of real numbers. We say that
    f(x) is O(g(x)) if there
  • are constants C and k such that
  • whenever x gt k. This is read as f(x) is
    big-oh of g(x).
  • Rosen, p.180

4
The Big-O notation
  • The definition says that after a certain point,
    namely after k, the
  • absolute value of f(x) is at most C times the
    absolute value of g(x).
  • The absolute value of a number, is the number
    without its sign.
  • Formally
  • C is a fixed constant. We are not allowed to
    increase it as x increases.

5
The Big-O notation
  • The constants C and k in the definition of big-O
    notation are called
  • witnesses to the relationship f(x) is O(g(x)).
  • If there is a pair of witnesses to the
    relationship f(x) is O(g(x)), then
  • there are infinitely many pairs of witnesses to
    that relationship.
  • Indeed, if C and k are one pair of witnesses,
    then any pair C and k,
  • where C lt C and k lt k, is also a pair of
    witnesses.
  • To establish that f(x) is O(g(x)) we need only
    one pair of witnesses to
  • this relationship.

6
Examples
  • Example 5.4 Rosen, p.181 Let
  • f(x) x2 2x 1
  • Prove that f(x) is in O(x2).
  • Proof For x gt 1, we have 1 lt x lt x2. That gives
  • f(x) x2 2x 1 x2 2x2 x2 4x2
  • Because the above equation holds for every
    positive integer x gt 1,
  • using k 1 and C 4 as witnesses, we get
  • f(x) Cx2, for every x gt k
  • showing that f(x) is O(x2).

7
Examples
  • Example 5.5 Show that f(x) 3x3 7x2 - 4x
    2 is O(x3).
  • Proof For all x gt 1, we have
  • So, for the pair of witnesses k 1, C 16, we
    have f(x) Cx3 for
  • every x gt k, giving f(x) O(x3).

8
Examples
  • Remark The inequality
  • can be obtained with repetitive use of the
    triangle inequality
  • Exercise 5.1 Using the triangle inequality show
    that

9
Big-O of polynomials
  • Proposition 5.1 Rosen, p.184 Any polynomial
    function is Big-O its
  • leading degree without leading constant.
  • Proof Let f(x) be a polynomial of degree k, that
    is,
  • with ak?0.

10
Big-O of polynomials
  • We have
  • With witnesses
  • and k 1, we have f(x) Cxk, for every x gt
    k, giving f(x) O(xk).

11
The Big-O notation
  • Some orders that often occur in practice are
Write a Comment
User Comments (0)
About PowerShow.com