80 likes | 288 Views
Discrete Structures – CNS2300. Text Discrete Mathematics and Its Applications Kenneth H. Rosen Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices. Section 2.2. The Growth of Functions. Big- O notation.
E N D
Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
Section 2.2 The Growth of Functions
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 |f(x)| <= C|g(x)| whenever x > k. Read f(x) is “big-oh” of g(x).
x f(x) g(x)1/4 5/16 3/16 2/4 25/16 12/16 3/4 33/16 27/16 4/4 48/16 48/16 5/4 65/16 75/16 Consider f(x) = x2 + 2x g(x) = 3x2 Let C=3 Let k=1
Suppose that f1(x) is O(g1(x)) and f2(x) are both O(g(x)) . Then (f1+f2)(x) isO(g(x)). The Growth of Combinations of Functions Suppose that f1(x) is O(g1(x)) and f2(x) is O(g2(x)) . Then (f1+f2)(x) isO(max(g1(x), g2(x))).
The Growth of Combinations of Functions Suppose that f1(x) is O(g1(x)) and f2(x) is O(g2(x)) . Then (f1f2)(x) isO( g1(x)g2(x)).
Computer Times Used by Algorithms n log nnnlog nn2 2nn! 10 3E-9 E-8 3E-8 E-7 E-6 3E-3 102 7E-9 E-7 7E-7 E-5 4E13yr * 103 1E-8 E-6 E-5 E-3 * * 104 1.3E-8 E-5 E-4 E-1 * * 105 1.7E-8 E-4 2E-3 10 * * 106 2E-8 E-3 2E-2 17min * * All times are in seconds unless otherwise stated. An * indicates a time of more than 10100 years.