This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 4. GROWTH OF FUNCTIONS 135 4. Growth of Functions 4.1. Growth of Functions. Given functions f and g , we wish to show how to quantify the statement: g grows as fast as f . The growth of functions is directly related to the complexity of algorithms. We are guided by the following principles. We only care about the behavior for large problems. We may ignore implementation details such as loop counter incrementation. Discussion When studying the complexity of an algorithm, we are concerned with the growth in the number of operations required by the algorithm as the size of the problem increases. In order to get a handle on its complexity, we first look for a function that gives the number of operations in terms of the size of the problem, usually measured by a positive integer n , to which the algorithm is applied. We then try to compare values of this function, for large n , to the values of some known function, such as a power function, exponential function, or logarithm function. Thus, the growth of functions refers to the relative size of the values of two functions for large values of the independent variable. This is one of the main areas in this course in which experience with the concept of a limit from calculus will be of great help. Before we begin, one comment concerning notation for logarithm functions is in order. Most algebra and calculus texts use log x to denote log 10 x (or, perhaps, log e x ), but in computer science base 2 is used more prevalently. So we shall use log x to denote log 2 x . As we shall see, in the context of this module it actually doesnt matter which base you use, since log a x = log b x log b a for any acceptable bases a and b . Exercise 4.1.1 . Prove that log a x = log b x log b a for arbitrary positive real numbers a and b different from 1. 4.2. The Big-O Notation. Definition 4.2.1 . Let f and g be functions from the natural numbers to the real numbers. Then g asymptotically dominates f , or f is big-O of g if there are positive constants C and k such that | f ( x ) | C | g ( x ) | for x k. 4. GROWTH OF FUNCTIONS 136 If f is big- O of g , then we write f ( x ) is O ( g ( x )) or f O ( g ). Theorem 4.2.1 . If lim x | f ( x ) | | g ( x ) | = L , where L , then f O ( g ) . Theorem 4.2.2 . If lim x | f ( x ) | | g ( x ) | = , then f is not O ( g ) ( f 6 O ( g )) . Discussion The most basic concept concerning the growth of functions is big-O . The statement that f is big- O of g expresses the fact that for large enough x , f will be bounded above by some constant multiple of g . Theorem 4.2.1 gives a necessary condition for f to be big- O of g in terms of limits. The two notions arent equivalent since there are examples where the definition holds, but the limit fails to exist. For the functions we will be dealing with, however, this will not happen....
View Full Document
- Fall '08