{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

notes02

# notes02 - 1 CSE 2320 Notes 2 Growth of Functions(Last...

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

CSE 2320 Notes 2: Growth of Functions (Last updated 3/26/12 13:56 A3/P3) Sedgewick 2.1-2.3 Why constants are annoying . . . Problem Instance of Size n Algorithm for Problem Language Compiler Machine clock memory levels word length instruction set Resources Consumed? Need to compare time and space usage of various algorithms for a problem. 2.A. A SYMPTOTIC N OTATION Sedgewick 2.4 Ο g n ( ) ( ) is a set of functions: f n ( ) Î O g n ( ) ( ) iff 5 c and n 0 such that f n ( ) £ cg n ( ) when n ³ n 0 f(n) g(n) cg(n) Theorem: If n ® ¥ lim f ( n ) g ( n ) is a constant, then f ( n ) O( g ( n )). 1

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

View Full Document
f ( n ) = n 2 , g ( n ) = n 3 n ® ¥ lim n 2 n 3 = n ® ¥ lim 2 n 3 n 2 = n ® ¥ lim 2 6 n = 0 Þ n 2 Î O( n 3 ) f ( n ) = n 3 , g ( n ) = n 2 n ® ¥ lim n 3 n 2 = n ® ¥ lim 3 n 2 2 n = n ® ¥ lim 6 n 2 = unbounded Þ n 3 Ï O( n 2 ) f ( n ) = 3 n 2 + 2 n – 3, g ( n ) = 5 n 2 n + 2 n ® ¥ lim 3 n 2 + 2 n - 3 5 n 2 - n + 2 = n ® ¥ lim 6 n + 2 10 n - 1 = n ® ¥ lim 6 10 = 3 5 Þ 3 n 2 + 2 n - 3 Î O(5 n 2 - n + 2) Conclusion: Toss out low-order terms n k Î O n l æ è ç ö ø ÷ if l ³ k . Is sin x ( ) Î O cos x ( ) ( )? cos(x) sin(x) Is ln x ( ) Î O log 10 x ( ) ( )? Is 2 n Î O n k æ è ç ö ø ÷ for some fixed k ? n k Î O 2 n æ è ç ö ø ÷ for any k . General case, n k Î O c n æ è ç ö ø ÷ for any c > 1 Be sure to appreciate Tables 2.1 and 2.2 in Sedgewick g n ( ) ( ) is a set of functions: f n ( ) Î W g n ( ) ( ) iff 5 c and n 0 such that f n ( ) ³ cg n ( ) c > 0 ( ) when n ³ n 0 2
g(n) f(n) cg(n) Theorem: If n ® ¥ lim g ( n ) f ( n ) is a constant, then f n ( ) Î W g n ( ) ( ). g n ( ) = n 2 , f n ( ) = 3 n 3 n ® ¥ lim n 2 3 n 3 = n ® ¥ lim 2 n 9 n 2 = n ® ¥ lim 2 18 n = 0 Þ n 3 Î W( n 2 ) Upper bounds (O()) are for particular algorithms . Lower bounds ( ()) are for indicating the inherent difficulty of problems .

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 12

notes02 - 1 CSE 2320 Notes 2 Growth of Functions(Last...

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

View Full Document
Ask a homework question - tutors are online