{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This preview shows pages 1–7. 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)
Image of page 1

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

View Full Document Right 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 !!!
Image of page 2
33 Now, suppose that algorithms A 1 and A 2 need the following amount of time: time complexity A 1 106 n O( n ) A 2 n 2 O( n 2) Which one is better ? A 1 is better if n > 106 A 2 is better if n < 106 Then, why time complexity ? Suppose that n Then, n 2 grows much faster than 106 n . i.e., Under the assumption that n A 1 is better than A 2 W Asymptotic growth rate !!! 10 6 n T ( n )
Image of page 3

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

View Full Document Right 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 .
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 ?
Image of page 5

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

View Full Document Right 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 ”.
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern