CS300-03_Algorithm_Analysis - 3. How to Measure...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
11 3. How to Measure Complexities How good is our measure of work done to compare algorithms ? How precisely can we compare two algorithms using our measure of work ? Measure of work # of passes of a loop # of basic operations Time complexity c 1 (measure of work)
Background image of page 1

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

View Full DocumentRight Arrow Icon
22 For solving a problem P , suppose that two algorithms A 1 and A 2 need 106 n and 5 n basic operations, respectively, i.e. basic operations A 1 106 n A 2 5 n Which one is better ? What are their time complexities ? A 1 c1∙ 106 n O( n ) A 2 c2∙ 5 n O( n ) Does this mean that A 1( A 2) is as good as A 2( A 1) ? Well, …… 1 Both # of basic operations (loops) and time complexity are imprecise !!!
Background image of page 2
Now, suppose that algorithms A 1 and A 2 need the following amount of time: time complexity A 1 106 n O( n ) 10 n T ( n )
Background image of page 3

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

View Full DocumentRight Arrow Icon
44 N = {0, 1, 2, …} N + = {1, 2, 3, …} R = the set of real numbers R + = the set of positive real numbers R * = R + {0} f : N R * and g : N R * g is: 1 ( f ): g grows at least as fast as f . 1 ( f ): g grows as the same rate as f . O( f ): g grows no faster than f .
Background image of page 4
55 Definition : Let f : N R * . O( f ) is the set of functions, g : N R * such that for some c R + and some n 0 N , g ( n ) c f ( n ) for all n n 0. O( f ) is usually called “big oh of f ”, “oh of f ”, or “order of f ”. Note: In other books, g ( n ) = O( f ( n )) if and only if there exist two positive constants c and n 0 such that | g ( n )| c | f ( n )| for all n n 0 Under the assumption that f : N R * and g: N R *, two definitions have a minor difference. How to check : n 2, 105 n 2 - n , n 2 + 1010, 103 n 2 + n - 1 O( n 2) Is 1010 n | O( n 2) ? What is it ?
Background image of page 5

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

View Full DocumentRight Arrow Icon
66 Definition : Let f : N R * . ( f ) is the set of functions, g : N R * such that for some c R + and some n 0 N , g ( n ) c 1 f ( n ) for all n n 0. 1 ( f ) is usually called “big omega of f ” or “omega of f ”. Note: In other books, g ( n ) = ( f ( n )) if and only if there exist two positive constants c and n 0 such that | g ( n )| c 1 | f ( n )| for all n n 0 How to check : 105 n , n 2, n 2 + 10 n + 106 ( n ). Are they also (log n ) ?
Background image of page 6
77 Definition : Let f : N R * . ( f ) = O( f ) ( f ).
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/07/2010 for the course CS 300 taught by Professor Shin during the Spring '10 term at Korea Advanced Institute of Science and Technology.

Page1 / 34

CS300-03_Algorithm_Analysis - 3. How to Measure...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online