Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.

Slides:



Advertisements
Similar presentations
HAWKES LEARNING SYSTEMS math courseware specialists Copyright © 2011 Hawkes Learning Systems. All rights reserved. Hawkes Learning Systems: College Algebra.
Advertisements

Copyright © Cengage Learning. All rights reserved. 10 Topics in Analytic Geometry.
Copyright © Cengage Learning. All rights reserved.
Origin: The point of intersection of the x and y axes.
PARAMETRIC EQUATIONS AND POLAR COORDINATES 9. Usually, we use Cartesian coordinates, which are directed distances from two perpendicular axes. Here, we.
Analytic Geometry in Three Dimensions
11 Analytic Geometry in Three Dimensions
Section 9.2 Vectors Goals Goals Introduce vectors. Introduce vectors. Begin to discuss operations with vectors and vector components. Begin to discuss.
Chapter one Linear Equations
1 Functions and Limits ..
Copyright © Cengage Learning. All rights reserved. 1 Functions and Limits.
Fall 2014 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
1 Preliminaries Precalculus Review I Precalculus Review II
Copyright © Cengage Learning. All rights reserved. 9 Topics in Analytic Geometry.
Copyright © Cengage Learning. All rights reserved. 0 Precalculus Review.
Copyright © Cengage Learning. All rights reserved. 1 Functions and Their Graphs.
Copyright © Cengage Learning. All rights reserved. Calculating Limits 1.4.
HAWKES LEARNING SYSTEMS math courseware specialists Copyright © 2011 Hawkes Learning Systems. All rights reserved. Hawkes Learning Systems: College Algebra.
Equations of Lines Chapter 8 Sections
Vectors and the Geometry of Space 9. Vectors 9.2.
Copyright © Cengage Learning. All rights reserved. 12 Vectors and the Geometry of Space.
Copyright © Cengage Learning. All rights reserved. Functions.
11 Table 2.1 defines a correspondence between a set of percent scores and a set of letter grades. For each score from 0 to 100, there corresponds only.
Vectors and the Geometry of Space 9. Three-Dimensional Coordinate Systems 9.1.
Slide 9- 1 Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Copyright © Cengage Learning. All rights reserved. Polar Coordinates and Parametric Equations.
Copyright © Cengage Learning. All rights reserved. 11 Infinite Sequences and Series.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
P.4 GRAPHS OF EQUATIONS Copyright © Cengage Learning. All rights reserved.
Copyright © 2011 Pearson Education, Inc. Equations and Graphs in Two Variables Section 1.3 Equations, Inequalities, and Modeling.
Chapter 9 Efficiency of Algorithms. 9.1 Real Valued Functions.
© 2010 Pearson Prentice Hall. All rights reserved. CHAPTER 7 Algebra: Graphs, Functions, and Linear Systems.
1 Copyright © Cengage Learning. All rights reserved. 3 Functions and Graphs 3.3 Lines.
1 Copyright © Cengage Learning. All rights reserved. 5. Inverse, Exponential and Logarithmic Functions 5.2 Exponential Functions.
1.3 The Cartesian Coordinate System
1 Copyright © Cengage Learning. All rights reserved. Functions 3.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
Chapter 7 Graphing Linear Equations REVIEW. Section 7.1 Cartesian Coordinate System is formed by two axes drawn perpendicular to each other. Origin is.
VECTORS AND THE GEOMETRY OF SPACE 10. VECTORS AND THE GEOMETRY OF SPACE In this chapter, we introduce vectors and coordinate systems for three-dimensional.
Copyright © Cengage Learning. All rights reserved Inequalities 2. Equations and Inequalities.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Copyright © Cengage Learning. All rights reserved. Functions and Graphs 3.
Functions 2 Copyright © Cengage Learning. All rights reserved.
Functions 2 Copyright © Cengage Learning. All rights reserved.
Section 7.1 The Rectangular Coordinate System and Linear Equations in Two Variables Math in Our World.
Review Chapter 1 Functions and Their Graphs. Lines in the Plane Section 1-1.
Copyright © Cengage Learning. All rights reserved. 1 Functions and Limits.
Copyright © Cengage Learning. All rights reserved. 1 Functions and Their Graphs.
Copyright © Cengage Learning. All rights reserved. CHAPTER The Six Trigonometric Functions The Six Trigonometric Functions 1.
Analytic Geometry in Three Dimensions
Copyright © Cengage Learning. All rights reserved.
Graphing Linear Equations
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
A Library of Parent Functions
Functions and Their Graphs
Copyright © Cengage Learning. All rights reserved.
Direct Proof and Counterexample V: Floor and Ceiling
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Algebra: Graphs, Functions, and Linear Systems
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Presentation transcript:

Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY

Copyright © Cengage Learning. All rights reserved. Real-Valued Functions of a Real Variable and Their Graphs SECTION 11.1

3 Real-Valued Functions of a Real Variable and Their Graphs A Cartesian plane or two-dimensional Cartesian coordinate system is a pictorial representation of R  R obtained by setting up a one-to-one correspondence between ordered pairs of real numbers and points in a Euclidean plane. To obtain it, two perpendicular lines, called the horizontal and vertical axes, are drawn in the plane. Their point of intersection is called the origin, and a unit of distance is chosen for each axis.

4 Real-Valued Functions of a Real Variable and Their Graphs An ordered pair (x, y) of real numbers corresponds to the point P that lies | x | units to the right or left of the vertical axis and | y | units above or below the horizontal axis. On each axis the positive direction is marked with an arrow. A real-valued function of a real variable is a function from one set of real numbers to another. If f is such a function, then for each real number x in the domain of f, there is a unique corresponding real number f (x).

5 Real-Valued Functions of a Real Variable and Their Graphs Thus it is possible to define the graph of f as follows:

6 Real-Valued Functions of a Real Variable and Their Graphs The definition of graph (see Figure ) means that for all x in the domain of f : Graph of a Function f Figure

7 Real-Valued Functions of a Real Variable and Their Graphs Note that if f (x) can be written as an algebraic expression in x, the graph of the function f is the same as the graph of the equation y = f (x) where x is restricted to lie in the domain of f.

8 Power Functions

9 A function that sends a real number x to a particular power, x a, is called a power function. For applications in computer science, we are almost invariably concerned with situations where x and a are nonnegative, and so we restrict our definition to these cases.

10 Example 1 – Graphs of Power Functions Plot the graphs of the power functions p 0, p 1/2, p 1, and p 2 on the same coordinate axes. Solution: Because the power function with exponent zero satisfies p 0 (x) = x 0 = 1 for all nonnegative numbers x, all points of the form (x, 1) lie on the graph of p 0 for all such x. So the graph is just a horizontal half-line of height 1 lying above the horizontal axis.

11 Example 1 – Solution Similarly, p 1 (x) = x for all nonnegative numbers x, and so the graph of p 1 consists of all points of the form (x, x) where x is nonnegative. The graph is therefore the half-line of slope 1 that emanates from (0, 0). Since for each nonnegative number any point with coordinates where x is nonnegative, is on the graph of p 1/2. cont’d

12 Example 1 – Solution For instance, the graph of p 1/2 contains the points (0, 0), (1, 1), (4, 2), and (9, 3). Similarly, since p 2 (x) = x 2, any point with coordinates (x, x 2 ) lies on the graph of p 2. Thus, for instance, the graph of p 2 contains the points (0, 0), (1, 1), (2, 4), and (3, 9). cont’d

13 Example 1 – Solution The graphs of all four functions are shown in Figure cont’d Figure Graphs of Some Power Functions

14 The Floor Function

15 The Floor Function The floor and ceiling functions arise in many computer science contexts. The next Example illustrates the graph of the floor function.

16 Example 2 – Graph of the Floor Function We have known that each real number either is an integer itself or sits between two consecutive integers: For each real number x, there exists a unique integer n such that The floor of a number is the integer immediately to its left on the number line. More formally, the floor function F is defined by the rule For each real number x,

17 Example 2 – Graph of the Floor Function = the greatest integer that is less than or equal to x = the unique integer n such that Graph the floor function. Solution: If n is any integer, then for each real number x in the interval, the floor of x,, equals n. Thus on each such interval, the graph of the floor function is horizontal; for each x in the interval, the height of the graph is n. cont’d

18 Example 2 – Solution It follows that the graph of the floor function consists of horizontal line segments, like a staircase, as shown in Figure The open circles at the right-hand edge of each step are used to show that those points are not on the graph. cont’d Figure Graph of the Floor Function

19 Graphing Functions Defined on Sets of Integers

20 Graphing Functions Defined on Sets of Integers Many real-valued functions used in computer science are defined on sets of integers and not on intervals of real numbers. Suppose you know what the graph of a function looks like when it is given by a certain formula on an interval of real numbers. You can obtain the graph of the function defined by the same formula on the integers in the interval by selecting out only those points on the known graph with integers as their first coordinates.

21 Graphing Functions Defined on Sets of Integers For instance, if f is the function defined by the same formula as the power function p 1 but having as its domain the set of nonnegative integers, then f (n) = n for all nonnegative integers n. The graphs of p 1, reproduced from Example 2, and f are shown side-by-side below. Graph of p 1 where p 1 (x) = x for all nonnegative real numbers x Graph of f where f (n) = n for all nonnegative integers n

22 Example 3 – Graph of a Function Defined on a Set of Integers Consider an integer version of the power function p 1/2. In other words, define a function g by the formula g(n) = n 1/2 for all nonnegative integers n. Draw the graph of g. Solution: Look at the graph of p 1/2 in Figure Draw the graph of g by reproducing only those points on the graph of p 1/2 with integer first coordinates. Figure Graphs of Some Power Functions

23 Example 3 – Solution Thus for each nonnegative integer n, the point (n, n 1/2 ) is on the graph of g. cont’d Graphs of g where g(n) = n 1/2 for all nonnegative integers n

24 Graph of a Multiple of a Function

25 Graph of a Multiple of a Function A multiple of a function is obtained by multiplying every value of the function by a fixed number. To understand the concept of O-notation, it is helpful to understand the relation between the graph of a function and the graph of a multiple of the function.

26 Graph of a Multiple of a Function If the graph of a function is known, the graph of any multiple can easily be deduced. Specifically, if f is a function and M is a real number, the height of the graph of Mf at any real number x is M times the quantity f (x). To sketch the graph of Mf from the graph of f, you plot the heights M  (f (x)) on the basis of knowledge of M and visual inspection of the heights f (x).

27 Example 4 – Graph of a Multiple of a Function Let f be the function whose graph is shown below. Sketch the graph of 2f.

28 Example 4 – Solution At each real number x, you obtain the height of the graph of 2f by measuring the height of the graph of f at x and multiplying that number by 2. The result is the following graph. cont’d

29 Example 4 – Solution Note that the general shapes of f and 2f are very similar, but the graph of 2f is “stretched out”: the “highs” are twice as high and the “lows” are twice as low. cont’d

30 Increasing and Decreasing Functions

31 Increasing and Decreasing Functions

32 Increasing and Decreasing Functions Figure illustrates the analytic definitions of increasing and decreasing. Figure

33 Increasing and Decreasing Functions It follows almost immediately from the definitions that both increasing functions and decreasing functions are one-to-one.

34 Example 5 – A Positive Multiple of an Increasing Function Is Increasing Suppose that f is a real-valued function of a real variable that is increasing on a set S of real numbers, and suppose M is any positive real number. Show that Mf is also increasing on S. Solution: Suppose x 1 and x 2 are particular but arbitrarily chosen elements of S such that x 1 < x 2. [We must show that (Mf)(x 1 ) < (Mf)(x 2 ).]

35 Example 5 – Solution From the facts that x 1 < x 2 and f is increasing, it follows that f (x 1 ) < f (x 2 ). Then Mf (x 1 ) < Mf (x 2 ), since multiplying both sides of the inequality by a positive number does not change the direction of the inequality. Hence, by definition of Mf, (Mf)(x 1 ) < (Mf)(x 2 ), and, consequently, Mf is increasing on S. cont’d

36 Increasing and Decreasing Functions It is also true that a positive multiple of a decreasing function is decreasing, that a negative multiple of a increasing function is decreasing, and that a negative multiple of a decreasing function is increasing.