CS336f1010 - 10/4/10 Example Lecture 10 CS336 F10...

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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)?
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

CS336f1010 - 10/4/10 Example Lecture 10 CS336 F10...

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

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