{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

COT5407-Class03-1

# COT5407-Class03-1 - GrowthRates Growthratesof functions...

This preview shows pages 1–9. Sign up to view the full content.

Analysis of Algorithms 1 Growth Rates Growth rates of  functions: Linear    n Quadratic    n 2 Cubic    n 3 In a log-log chart,  the slope of the line  corresponds to the  growth rate of the  function 1E+0 1E+2 1E+4 1E+6 1E+8 1E+10 1E+12 1E+14 1E+16 1E+18 1E+20 1E+22 1E+24 1E+26 1E+28 1E+30 1E+0 1E+2 1E+4 1E+6 1E+8 1E+10 n T ( n ) Cubic Quadratic Linear

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Analysis of Algorithms 2 Constant Factors The growth rate is  not affected by constant factors or  lower-order terms Examples 10 2 n + 10 5 is a linear  function 10 5 n 2 + 10 8 n is a  quadratic function 1E+0 1E+2 1E+4 1E+6 1E+8 1E+10 1E+12 1E+14 1E+16 1E+18 1E+20 1E+22 1E+24 1E+26 1E+0 1E+2 1E+4 1E+6 1E+8 1E+10 n T ( n ) Quadratic Quadratic Linear Linear
Analysis of Algorithms 3 Big-Oh Notation Given functions  f ( n ) and  g ( n ) , we say that  f ( n ) is  O ( g ( n ))  if there are  positive constants c  and  n 0  such that f ( n )     cg ( n ) for  n   n 0 Example:  2 n + 10  is  O ( n ) 2 n + 10   cn ( c - 2) n 10 n 10 / ( c - 2) Pick  c = 3 and  n 0 = 10 1 10 100 1,000 10,000 1 10 100 1,000 n 3n 2n+10 n

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Analysis of Algorithms 4 Big-Oh Example Example: the function  n 2 is not  O ( n ) n 2   cn n   c The above inequality  cannot be satisfied  since  c  must be a  constant  1 10 100 1,000 10,000 100,000 1,000,000 1 10 100 1,000 n n^ 2 100n 10n n
Analysis of Algorithms 5 More Big-Oh Examples 7n-2 7n-2 is O(n) need c > 0 and n 0    1 such that 7n-2   c•n for n   n 0 this is true for c = 7 and n 0  = 1 3n 3  + 20n 2  + 5 3n 3  + 20n 2  + 5 is O(n 3 ) need c > 0 and n 0    1 such that 3n 3  + 20n 2  + 5   c•n 3  for n   n 0 this is true for c = 4 and n 0  = 21 3 log n + log log n 3 log n + log log n is O(log n) need c > 0 and n 0    1 such that 3 log n + log log n   c•log n for n   n 0 this is true for c = 4 and n 0  = 2

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Analysis of Algorithms 6 Big-Oh and Growth Rate The big-Oh notation gives an upper bound on the  growth rate of a function The statement “ f ( n ) is  O ( g ( n )) ” means that the growth  rate of  f ( n ) is no more than the growth rate of  g ( n ) We can use the big-Oh notation to rank functions  according to their growth rate f ( n ) is  O ( g ( n )) g ( n ) is  O ( f ( n )) g ( n ) grows more Yes No f ( n ) grows more No Yes Same growth Yes Yes
Analysis of Algorithms 7 Big-Oh Rules If is  f ( n )  a polynomial of degree  d , then  f ( n )  is  O ( n d ) , i.e., 1. Drop lower-order terms 2. Drop constant factors Use the smallest possible class of functions Say “ 2 n  is  O ( n ) instead of “ 2 n  is  O ( n 2 ) Use the simplest expression of the class Say “ 3 n + 5  is  O ( n ) instead of “ 3 n + 5  is  O (3 n )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Analysis of Algorithms 8 Relatives of Big-Oh big-Omega f(n) is  (g(n)) if there is a constant c > 0
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 28

COT5407-Class03-1 - GrowthRates Growthratesof functions...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online