Upcoming SlideShare
×

# Clase3 Notacion

1,302
-1

Published on

Descripción de las Notaciones asintoticas

Published in: Education, Business, Real Estate
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
1,302
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
18
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Clase3 Notacion

1. 1. A A nalisis de lgoritmos Informacion tomada del libro de Cormen.
2. 2. OUTLINE <ul><li>Growth of Functions </li></ul><ul><ul><li>Asymptotic notation </li></ul></ul><ul><ul><li>Common functions </li></ul></ul>
3. 3. ASYMPTOTIC NOTATION
4. 4. Asymptotically N o Negative Functions f(n) is asymptotically no negative if there exist n 0  N such that for every n  n 0 , 0  f(n) n 0 f
5. 5. Theta   ( g(n) ) = { f : N  R * | (  c 1 , c 2  R + ) (  n 0  N) (  n  n 0 ) ( 0  c 1 g(n)  f(n)  c 2 g(n) ) } c 1  lim f(n)  c 2 n  g(n ) n 0 g c 1 g f c 2 g
6. 6. <ul><li>“ f (n) =  (g(n))”  “ f (n)   (g(n))” </li></ul><ul><li>f is asymptotically tight bound for g </li></ul><ul><li>or </li></ul><ul><li>f is of the exact order of g </li></ul><ul><li>Every member of  (g(n)) is asymptotically no negative </li></ul><ul><li>The function g(n) must itself asymptotically no negative, or else  (g(n)) =  . </li></ul>
7. 7. Example Lets show that We have to find c 1 , c 2 and n 0 such that
8. 8. For all n  n 0 , Dividing by n 2 yields We have that 3/n is a decreasing sequence 3, 3/2, 1, 3/4, 3/5, 3/6, 3/7… and then 1/2 - 3/n is increasing sequence -5/2, -1, -1/2, -1/4, -1/10, 0, 1/14 that is upper bounded by 1/2 .
9. 9. The right hand inequality can be made to hold for n  1 by choosing c 2  1/2 . Likewise the left hand inequality can be made to hold for n  7 by choosing c 1  1/14 .
10. 10. Thus by choosing c 1 = 1/14 , c 2 = 1/2 and n 0 =7 then we can verify that
11. 11. Big O O (g(n)) = { f : N  R * | (  c  R + ) (  n 0  N) (  n  n 0 ) ( 0  f(n)  cg(n) ) } lim f(n)  c n  g(n) n 0 g cg f
12. 12. <ul><li>“ f (n) = O (g(n))”  “ f (n)  O (g(n))” </li></ul><ul><li>f is asymptotically upper bounded for g </li></ul><ul><li>or </li></ul><ul><li>g is an asymptotic upper bound for f </li></ul><ul><li>O (g(n)) is pronounced “big oh of g(n) ” </li></ul>
13. 13. Example Lets show that We have to find c and n 0 such that
14. 14. For all n  n 0 , Dividing by n yields The inequality can be made to hold for n  1 by choosing c  a+b . Thus by choosing c = a+b and n 0 =1 then we can verify that
15. 15. n 0 =1 a+b b a
16. 16. Big Omega   ( g(n) ) = { f : N  R * | (  c  R + ) (  n 0  N) (  n  n 0 ) ( 0  cg(n)  f(n) ) } c  lim f(n) n  g(n) n 0 g f cg
17. 17. <ul><li>“ f (n) =  (g(n))”  “ f (n)   (g(n))” </li></ul><ul><li>f is asymptotically lower bounded for g </li></ul><ul><li>or </li></ul><ul><li>g is an asymptotic lower bound for f </li></ul><ul><li>O (g(n)) is pronounced “big omega of g(n) ” </li></ul>
18. 18. Little o o (g(n)) = { f : N  R * | (  c  R + ) (  n 0  N) (  n  n 0 ) ( 0  f(n) < cg (n) ) } lim f(n) = 0 n  g(n) “ o(g(n)) functions that grow slower than g ” g f
19. 19. <ul><li>“ f (n) = o (g(n))”  “ f (n)  o (g(n))” </li></ul><ul><li>f is asymptotically smaller than g </li></ul><ul><li>o (g(n)) is pronounced “little-oh of g(n) ” </li></ul>
20. 20. n 2 n Examples Lets show that We only have to show
21. 21. Lets show that We have 3n n
22. 22. Little Omega   ( g(n) ) = { f : N  R * | (  c  R + ) (  n 0  N) (  n  n 0 ) ( 0  c g(n) < f(n ) ) } lim f(n) =  n  g(n) “  (g(n)) functions that grow faster than g ” f g
23. 23. <ul><li>“ f (n) =  (g(n))”  “ f (n)   (g(n))” </li></ul><ul><li>f is asymptotically larger than g </li></ul><ul><li>o (g(n)) is pronounced “little-omega of g(n) ” </li></ul>
24. 24. Analogy with the comparison of two real numbers Asymptotic Real Notation numbers f(n)  O(g(n)) f  g f(n)   (g(n)) f  g f(n)   (g(n)) f = g f(n)  o(g(n)) f < g f(n)   (g(n)) f > g Trichotomy does not hold
25. 25. Not all functions are asymptotically comparable Example f(n)=n g(n)=n (1+sin n) (1+sin(n))  [0,2]
26. 26. <ul><li>The running time of an algorithm is  (f(n)) </li></ul><ul><ul><ul><ul><li>iff </li></ul></ul></ul></ul><ul><li>Its worst-case running time is O(f(n)) and </li></ul><ul><li>Its best-case running time is  (f(n)) </li></ul> (f(n))=O(f(n))   (f(n)) Properties
27. 27. <ul><li>Transitivity of O,  ,  </li></ul><ul><li>f(n)   (g(n)) and g(n)   (h(n)) then f(n)   (h(n)) ; </li></ul><ul><li>for  = O,  ,  </li></ul><ul><li>Reflexivity of O,  ,  </li></ul><ul><ul><li>f(n)   (f(n)) ; for  = O,  ,  </li></ul></ul><ul><li>Symmetry of  </li></ul><ul><ul><li>f(n)   (g(n))  g(n)   (f(n)) </li></ul></ul><ul><li>Anti-symmetry of O,  </li></ul><ul><ul><li> f(n)   (g(n)) </li></ul></ul><ul><ul><li>f(n)   (g(n))  g(n)   (f(n)) ; for  = O,  </li></ul></ul><ul><li>Transpose Symmetry </li></ul><ul><li>f(n)  O(g(n))  g(n)   (f(n)) </li></ul><ul><li>f(n)  o(g(n))  g(n)   (f(n)) </li></ul>
28. 28. <ul><li>f  g  f(n)  O(g(n)) order relation </li></ul><ul><ul><li>reflexive </li></ul></ul><ul><ul><li>anti-symmetric </li></ul></ul><ul><ul><li>transitive </li></ul></ul><ul><li>f  g  f(n)   (g(n)) order relation </li></ul><ul><ul><li>reflexive </li></ul></ul><ul><ul><li>anti-symmetric </li></ul></ul><ul><ul><li>transitive </li></ul></ul><ul><li>f = g  f(n)   (g(n)) equivalence relation </li></ul><ul><ul><li>reflexive </li></ul></ul><ul><ul><li>symmetric </li></ul></ul><ul><ul><li>transitive </li></ul></ul>
29. 29. <ul><li>Relation between o and O </li></ul><ul><li>f(n)  o(g(n))  f(n)  O(g(n)) </li></ul><ul><li>Relation between  and  </li></ul><ul><li>g(n)   (f(n))  g(n)   (f(n)) </li></ul>o (f(n))   (f(n)) = 
30. 30. Examples <ul><li>A B </li></ul><ul><li>5n 2 + 100n 3n 2 + 2 </li></ul><ul><li>log 3 (n 2 ) log 2 (n 3 ) </li></ul><ul><li>n lg4 3 lg n </li></ul><ul><li>lg 2 n n 1/2 </li></ul>
31. 31. Examples <ul><li>A B </li></ul><ul><li>5n 2 + 100n 3n 2 + 2 A   (B) </li></ul><ul><li>log 3 (n 2 ) log 2 (n 3 ) A   (B) </li></ul><ul><li>n lg4 3 lg n A   (B) </li></ul><ul><li>lg 2 n n 1/2 A   (B) </li></ul>
32. 32. Examples <ul><li>A B </li></ul><ul><li>5n 2 + 100n 3n 2 + 2 A   (B) </li></ul><ul><ul><li>A   ( n 2 ), n 2   (B)  A   (B) </li></ul></ul><ul><li>log 3 (n 2 ) log 2 (n 3 ) A   (B) </li></ul><ul><ul><li>log b a = log c a / log c b ; A = 2lgn / lg3 , B = 3lgn , A/B = 2/(3lg3) </li></ul></ul><ul><li>n lg4 3 lg n A   (B) </li></ul><ul><ul><li>a log b = b log a ; B = 3 lg n = n lg 3 ; A/B = n lg(4/3)   as n  </li></ul></ul><ul><li>lg 2 n n 1/2 A   (B) </li></ul><ul><ul><li>lim ( log a n / n b ) = 0, here a = 2 and b = 1/2  A   (B) </li></ul></ul><ul><ul><li>n  </li></ul></ul>
33. 33. Asymptotic notation two variables O(g(m, n))= { f: N  N  R * | (  c  R + )(  m 0 , n 0  N) (  n  n 0 ) (  m  m 0 ) (f(m, n)  c g(m, n)) }
34. 34. COMMON FUNCTIONS
35. 35. Monotonicity <ul><li>f is monotonically increasing if </li></ul><ul><li>  m  n  f(m)  f(n) </li></ul><ul><li>f is monotonically decreasing if </li></ul><ul><li>  m  n  f(m)  f(n) </li></ul><ul><li>f is strictly increasing if </li></ul><ul><li>  m < n  f(m) < f(n) </li></ul><ul><li>f is strictly decreasing if </li></ul><ul><li>  m < n  f(m) > f(n) </li></ul>
36. 36. Floors and Ceilings <ul><li> x  floor of x </li></ul><ul><li>the greatest integer less than or equal to x </li></ul><ul><li> x  ceiling of x </li></ul><ul><li>the smallest integer greater than or equal to x </li></ul><ul><li> x  R , x-1 <  x   x   x  < x +1 </li></ul><ul><li> n  N ,  n  = n =  n  and  n/2  +  n/2  = n </li></ul>-1 0 1  x  -2 2  x  x
37. 37. <ul><li> x  R and integers a,b > 0 </li></ul><ul><ul><ul><ul><li>  x / a  /b  =  x / a b  . </li></ul></ul></ul></ul><ul><ul><ul><ul><li>  x / a  /b  =  x / a b  . </li></ul></ul></ul></ul><ul><ul><ul><ul><li> a /b   ( a + (b-1)) /b. </li></ul></ul></ul></ul><ul><ul><ul><ul><li> a /b  ( a - (b-1)) /b. </li></ul></ul></ul></ul><ul><li> x  and  x  are monotonically increasing </li></ul>
38. 38. Modular arithmetic For every integer a and any possible positive integer n, a mod n is the remainder of ( or residue ) of the quotient a/n a mod n = a -  a / n  n.
39. 39. congruency or equivalence mod n If ( a mod n) = ( b mod n) we write a  b ( mod n) and we say that a is equivalent to b modulo n or that a is congruent to b modulo n. In other words a  b ( mod n) if a and b have the same remainder when divided by n . Also a  b ( mod n) if and only if n is a divisor of b-a.
40. 40. 0 1 2 3 -4 -3 -2 -1 -8 -7 -6 -5 -12 -11 -10 -9         12 13 14 15 8 9 10 11 4 5 6 7     Example  (mod 4)  (mod n) defines a equivalence relation in Z and produces a partitioned set called Z n = Z /n = {0,1,2,…, n -1} in which can be defined arithmetic operations a+b (mod n) a*b (mod n) [0] [1] [2] [3] Z /4 = {[0],[1],[2],[3]} = {0,1,2,3} 4+1 ( mod 4) = 1 5*2 ( mod 4) = 2
41. 41. Polynomials Given a no negative integer d, a polynomial in n of degree d is a function p(n) of the form: Where a 1 , a 2 , …, a d are the coefficients and a d  0.
42. 42. <ul><li>A polynomial p(n) is asymptotically positive </li></ul><ul><li>if and only if a d > 0. </li></ul><ul><li>If p(n), of degree d, is asymptotically positive, we have p(n)=  (n d ). </li></ul><ul><li> a  R , a  0, n a is monotonically increasing. </li></ul><ul><li> a  R , a  0, n a is monotonically decreasing. </li></ul><ul><li>A function f(n) is polynomially bounded if </li></ul><ul><li>f(n)= O (n d ) for some constant d. </li></ul>
43. 43. Exponentials <ul><li>For all reals a  0, m and n, we have the following identities </li></ul><ul><ul><ul><ul><ul><li>a 0 = 1 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>a 1 = a </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>a -1 = 1/a </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>( a m ) n = a mn </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>( a m ) n = ( a n ) m </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>a m a n =a m+n </li></ul></ul></ul></ul></ul>
44. 44. <ul><li>If a  0 and for all n, </li></ul><ul><ul><ul><li>a n is monotonically increasing. </li></ul></ul></ul><ul><li> a,b  R , a >1 , </li></ul><ul><ul><ul><ul><ul><li>then n d = o ( a n ) </li></ul></ul></ul></ul></ul>
45. 45. <ul><li> x  R, e x  1+x, equality holds for x=0. </li></ul><ul><li>If | x|  1 1+x  e x  1+x+ x 2 . </li></ul><ul><li>When x  0, e x = 1+x + O( x 2 ) . </li></ul>
46. 46. Logarithms <ul><li>Notations: </li></ul><ul><ul><ul><ul><ul><li>lg n = log 2 n </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>ln n = log e n </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>lg k n = (lg n ) k </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>lg lg n = lg (lg n ) </li></ul></ul></ul></ul></ul><ul><li>Logarithms function will only apply to next term in the </li></ul><ul><li>formula </li></ul><ul><li>lg n + k = ( lg n ) +k. </li></ul><ul><li>For b > 1 constant and n > 0, </li></ul><ul><li>log b n </li></ul><ul><li>is strictly increasing. </li></ul>
47. 47. <ul><li>For all reals a > 0, b > 0, c > 0 and n we have the following identities </li></ul><ul><ul><ul><ul><ul><li>log c ( ab ) = log c a + log c b. </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>log b a n = n log b a. </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>log b (1/ a n ) = - log b a. </li></ul></ul></ul></ul></ul>
48. 48. <ul><li>when x > -1 </li></ul><ul><li>For x > -1 </li></ul><ul><li>equality holds for x=0. </li></ul>
49. 49. A function f(n) is polylogaritmically bounded if f(n)= O ( lg k n) for some constant k. We have the following relation between polynomials and polylogarithms: then lg k n = o ( n k )
50. 50. Factorials Definition (no recursive) (recursive) Weak upper bound n!  n n
51. 51. <ul><li>Stirling´s approximation </li></ul><ul><li> </li></ul><ul><li>then </li></ul><ul><ul><ul><ul><ul><li>n! = o ( n n ) </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>n! =  ( 2 n ) </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>lg (n!) =  ( n lgn ) </li></ul></ul></ul></ul></ul>
52. 52. <ul><li> </li></ul><ul><li>where </li></ul>
53. 53. Functional iteration Given a function f ( n ) the i-th functional iteration of f is defined as : with I the identity function. For a particular n , we have,
54. 54. Examples: f(n) = 2n then f(n) = n 2 then
55. 55. f(n) = n n then
56. 56. Iterated logarithm <ul><li>The iterated logarithm of n , denoted lg * n </li></ul><ul><li>“ log star of n” is defined as </li></ul><ul><li>lg * n , is a very slowly growing function </li></ul><ul><ul><ul><ul><ul><li> lg * 1 = 0 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li> lg * 2 = 1 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li> lg * 4 = 2 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li> lg * 16 = 3 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>lg * 65536 = 4 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>lg * (65536) 2 = 5 </li></ul></ul></ul></ul></ul>
57. 57. In general k
1. #### A particular slide catching your eye?

Clipping is a handy way to collect important slides you want to go back to later.