360 likes | 476 Views
CS 23022 Discrete Mathematical Structures. Mehdi Ghayoumi MSB rm 132 mghayoum@kent.edu Ofc hr: Thur, 9:30-11:30a. Announcements. Homework 4 available. Due Mon 06/23 , 8a. Midterm : Next Mon 06/30/14, location 121 . Chapter 2.3 in Rosen and some other articles And Chapter 3 in Rosen.
E N D
CS 23022Discrete Mathematical Structures Mehdi Ghayoumi MSB rm 132 mghayoum@kent.edu Ofc hr: Thur, 9:30-11:30a
Announcements Homework 4 available. Due Mon 06/23, 8a. Midterm : Next Mon 06/30/14, location 121. Chapter 2.3 in Rosen and some other articles And Chapter 3 in Rosen
Familiar functions Polynomials: f(x) = a0xn + a1xn-1 + … + an-1x1 + anx0 A polynomial can have: A polynomial can have constants, variables and exponents, but never division by a variable.
Familiar functions Degree Standard Form
Familiar functions Exponentials: The exponential function with base b is defined by:
Familiar functions Natural Exponential Function: This function is simply a "version" of where b >1.
Familiar functions Inverse of f (x) = ex: Since f (x) = exis a one-to-one function, weknow that its inverse will also be a function. But what is the equation of the inverse of f (x) = ex ?To solve for an inverse algebraically:
Familiar functions Other Exponential Inverses: Y=2x or y= 0.5x
In this course, log2 n is written lg n. If we write log n, assume log2 n. Familiar functions Logarithms: log2 x = y, where 2y = x. f(x) = loga(x) a is any value greater than 0, except 1 Example: f(x) = log2(x) Example: f(x) = log½(x)
Familiar functions Inverse loga(x) is the Inverse Function of ax (the Exponential Function) The Natural Logarithm Function This is the "Natural" Logarithm Function: f(x) = loge(x) Where e is "Eulers Number" = 2.718281828459 (and more ...)
Familiar functions Ceiling: f(x) = x the least integer y so that x y. Ex: 1.2 = 2; -1.2 = -1; 1 = 1
Familiar functions Floor: f(x) = x the greatest integer y so that x y. Ex: 1.8 = 1; -1.8 = -2; -5 = -5
Familiar functions Cube Function Linear Function Square Function f(x) = x3 f(x) = mx + b f(x) = x2
Familiar functions Reciprocal Function Square Root Function Absolute Value Function f(x) = √x f(x) = |x| f(x) = 1/x
Familiar functions Logarithmic Function Exponential Function f(x) = ln(x) f(x) = ex
Familiar functions Dance Moves
Every unit increase in x results in the same increase in f(x). Linear functions Function types Describe these functions: f(x) x
Very slow growing. Logarithmic function Function types Describe this function:
Very fast growing. Exponential function Function types Describe this function:
Polynomial Function types Describe this function: f(x) x
In this case our algorithm takes about n time units. We say the algorithm has “order n” running time. Two example algorithms Suppose we wish to find the maximum number in a sequence of n numbers. How long should we spend doing this? Suppose it takes 1 time unit to make a comparison between two numbers.
In this case the algorithm takes about lg n time units. We say the algorithm has “order log n” running time. Two example algorithms I have a number between 0 and 63. You ask a question, I’ll tell you yes or no. How long will it take you to find my secret number? Suppose it takes 1 time unit to answer a query about my number.
Who is the tortoise? Who is the hare? How would you describe blue’s performance? At each distance, who wins? Who wins the race? The following graph gives times for completing races of length x, for 4 different competitors. time distance
Growth of functions Algorithm analysis is concerned with: Type of function that describes run time (we ignore constant factors since different machines have different speed/cycle) Large values of x
We say “f(x) is big O of g(x)” Recipe for proving f(x) = O(g(x)): find a c and k so that the inequality holds. Growth of functions Important definition: For functions f and g we write f(x) = O(g(x)) to denote c,k so that x>k, f(x) c·g(x)
c·g(x) g(x) We give an eventual upper bound on f(x) k Growth of functions f(x) = O(g(x)) iff c,k so that x>k, f(x) c·g(x) f(x) x
There’s k There’s c Growth of functions (examples) f(x) = O(g(x)) Iff c,k so that x>k, f(x) c·g(x) 3n = O(15n) since n>0, 3n 1·15n
5 8 0 5 Growth of functions (examples) f(x) = O(g(x)) iff c,k so that x>k, f(x) c·g(x) 15n = O(3n) since n>__, 15n __·3n
1 Growth of functions (examples) f(x) = O(g(x)) iff c,k so that x>k, f(x) c·g(x) x2 = O(x3) since x> __, x2 x3
0 1000 Growth of functions (examples) f(x) = O(g(x)) iff c,k so that x>k, f(x) c·g(x) 1000x2 = O(x2) since x> __, 1000x2 ____·x2
Growth of functions (examples) f(x) = O(x4).
Nothing works for k Try c = 10 k = 200, c = 11 Try c = 11 200 Growth of functions (examples) Prove that 5x + 100 = O(x/2) Need x> ___, 5x + 100 ___ · x/2 x> ___, 5x + 100 10 · x/2 x> ___, 5x + 100 5x + x/2 x> ___, 100 x/2
Growth of functions Guidelines: In general, only the largest term in a sum matters. a0xn + a1xn-1 + … + an-1x1 + anx0 = O(xn) n5lg n = O(n6) List of common functions in increasing O() order: 1 (lgn ) n (n lg n) n2… 2n n!
This is just the case where g1(x) = g2(x) = g(x) Growth of functions - a corollary If f1(x) = O(g1(x)) and f2(x)=O(g2(x)), then f1(x) + f2(x) = O(max{g1(x),g2(x)}) If f1(x) = O(g(x)) and f2(x)=O(g(x)), then f1(x) + f2(x) = O(g(x)).