210 likes | 320 Views
CS 23022 Discrete Mathematical Structures. Mehdi Ghayoumi MSB rm 132 mghayoum@kent.edu Ofc hr: Thur, 9:30-11:30a. Announcements. Homework 5 available. Due 06/26, 8a. Midterm 1: 06/30/14, Chapter 3 in Rosen and some other articles. Growth of functions - another theorem. If
E N D
CS 23022Discrete Mathematical Structures Mehdi Ghayoumi MSB rm 132 mghayoum@kent.edu Ofc hr: Thur, 9:30-11:30a
Announcements • Homework 5 available. Due 06/26, 8a. • Midterm 1: 06/30/14, • Chapter 3 in Rosen and some other articles.
Growth of functions - another theorem If f1(x) = O(g1(x)) and f2(x)=O(g2(x)), then f1(x)·f2(x) = O(g1(x)·g2(x))
Growth of functions Algorithm “Good Morning” For I = 1 to n For J = I+1 to n Shake Hands(student(I), student(J)) Running time of “Good Morning” Time = (# of HS) x (time/HS) + some overhead We want an expression for T(n), running time of “Good Morning” on input of size n.
2 Growth of functions Algorithm “Good Morning” For I = 1 to n For J = I+1 to n ShakeHands(student(I), student(J)) How many handshakes? J n2 - n I
= O(n2) if ShakeHands() runs in constant time. Growth of functions Algorithm “Good Morning” For I = 1 to n For J = I+1 to n ShakeHands(student(I), student(J)) T(n) = s(n2- n)/2 + t Where s is time for one HS, and t is time for getting organized.
Growth of functions • Use the definition of O-notationto express|17x6 – 3x3 + 2x + 8| ≤ 30|x6| for all x > 1 • M = 30 • x0 = 1 • 17x6 – 3x3 + 2x + 8 is O(x6)
Growth of functions 30x6 17x6 – 3x3 + 2x + 8 x6
Growth of functions • Use the definition of O-notationto expressfor all x > 6 • M = 45 • x0 = 6
O -notation For function g(n), we define O(g(n)), big-O of n, as the set: O(g(n)) = {f(n) : positive constants c and n0, such that n n0, we have f(n) cg(n)}
-notation For function g(n), we define (g(n)), big-Omega of n, as the set: (g(n)) = {f(n) : positive constants c and n0, such that n n0, we have 0 cg(n) f(n)}
-notation For function g(n),define (g(n)), big-Theta of n, as the set: (g(n)) = {f(n) : positive constants c1, c2, and n0, such that n n0, we have 0 c1g(n) f(n) c2g(n)}
“f is little-o of g” Growth of functions - other estimates f = o(g) o(g(n)) = {f(n) : positive constants c>0 and n0, such that n n0, we have 0 f(n)cg(n) }
This inequality holds when n > 21/c. So, k = 21/c. Growth of functions - other estimates Example: Show that n2 = o(n2log n) Choose c arbitrarily. How large does n have to be so that n2 c n2log n? 1 c log n 1/c log n 21/c n
This inequality holds when n > 10/c. So, k = 10/c. Growth of functions - other estimates Example: Show that 10n2 = o(n3) Proof : find a k (possibly in terms of c) that makes the inequality hold. Choose c arbitrarily. How large does n have to be so that 10n2 c n3? 10/c n
Comparison of Functions f g a b f (n) = O(g(n)) a b f (n) = (g(n)) a b f (n) = (g(n)) a = b f (n) = o(g(n)) a <b
Comparison of Functions If f(x) = O(g(x)), and f(x) = (g(x)), then f(x) = (x)
“f is big-theta of g” When we write f=O(g), it is like f g When we write f= (g), it is like f g When we write f= (g), it is like f = g. Comparison of Functions