# The Design and Analysis of Computer Algorithms

Rate of Growth of Functions Throughout this book we derive mathematical expressions for quantities such as space, time, and circuit size. Generally these expressions describe functions f : → from the nonnegative integers to the reals, such as the functions f1(n) and f2(n) defined as f1(n) = 4.5n2 + 3n f2(n) = 3n + 4.5n2 When n is large we often wish to simplify expressions such as these to make explicit their dominant or most rapidly growing term. For example, for large values of n the dominant terms in f1(n) and f2(n) are 4.5n2 and 3n respectively, as we show. A term dominates when n is large if the value of the function is approximately the value of this term, that is, if the function is within some multiplicative factor of the term. To highlight dominant terms we introduce the big Oh, big Omega and big Theta notation. They are defined for functions whose domains and codomains are the integers or the reals. DEFINITION 1.2.1 Let f : → and g : → be two functions whose domains and codomains are either the integers or the reals. If there are positive constants x0 and K > 0 such that for all |x| ≥ x0, |f(x)| ≤ K |g(x)| we write f(x) = O(g(x)) and say that “f(x) is big Oh of g(x)” or it grows no more rapidly in x than g(x). Under the same conditions we also write g(x) = Ω(f(x) 14 Chapter 1 The Role of Theory in Computer Science Models of Computation and say that “g(x) is big Omega of f(x)” or that it grows at least as rapidly in x as f(x). If f(x) = O(g(x)) and g(x) = O(f(x)), we write f(x) = Θ(g(x)) or g(x) = Θ(f(x)) and say that “f(x) is big Theta of g(x)” and “g(x) is big Theta of f(x)” or that the two functions have the same rate of growth in x