{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS336f1010 - Example Lecture 10 CS336 F10 y=f(x)=3x2 43x...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
10/4/10 1 Lecture 10 CS336 F10 Asymptotic Dominance Example y=f(x)=3x 2 +43x+110 f(19)= Example: Horner’s rule Recall : y = a[0] + a[1] x + … + a[n-1]x n-1 = a[0] + ( a[1] + (a[2] + … (a[n-2] + a [n-1] x ) x ) … ) x The first (dumb) way requires n-1 additions and 0 + 1 + 2 + … + n-1 = n(n-1)/2 multiplications The second way (Horner’s rule) requires n-1 additions and n-1 multiplications Dumb evaluation vs. Horner’s rule
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
10/4/10 2 Uses for Big-O Give a big-O estimate for • n 3 + n 2 (log n+1) + (17 log(( n +19) (n 3 +2))) • n!+2 n Definition Let f and g be functions from N to R. Then g asymptotically dominates f or f is O(g) ( k,C| : ( x| x>k: |f(x)| C|g (x)|)) That is, there exists constants k and C such that |f(x)| C|g (x)| for all x>k Example Let f(n) = n and g(n) = -n 3 . Is it the case that f is O(g)? Yes |n| |-n 3 | for n 1 so by the definition of big O with C=1 and k=1, f is O(g) Example Let f(n) = n and g(n) = -n 3 . Is it the case that g is O(f)? No. Assume|-n 3 | C|n| for all n >k. Then n 2 C for all n>k.
Image of page 2
Image of page 3
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