1 / 23

Chapter 3 Growth of Functions

Chapter 3 Growth of Functions. ex.2.3-4 p39 Sort A[1…n] by recursively sorting A[1…n-1] then insert A[n] Write recurrence for run time. Solution: T(n) = T(n-1) + O(n) Rationale for O(n)? What is the solution of this recurrence?. (defined as set of functions).

leora
Télécharger la présentation

Chapter 3 Growth of Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 3 Growth of Functions

  2. ex.2.3-4 p39 Sort A[1…n] by recursively sorting A[1…n-1] then insert A[n] Write recurrence for run time. Solution: T(n) = T(n-1) + O(n) Rationale for O(n)? What is the solution of this recurrence?

  3. (defined as set of functions) Used to denote worst case, as in insertion sort T(n) = O(n2) Allows for possibility that f(n) = cg(n) for large n To prove T(n) = O(n), find a combination of c and n0 (may not be unique)

  4. Used to denote best case run time Allows for possibility that f(n) = cg(n) for large n To prove T(n) = W(n), find a combination of c and n0 (may not be unique)

  5. T(n) = Q(n) iff T(n) = O(n) and T(n) = W(n) Theorem 3.1 At large n, f(n) and g(n) are equal within a constant factor To prove T(n) = Q(n), use Theorem 3.1

  6. Ex 3.1-1 text p52: show that max(f(n),g(n)) = Q(f(n) + g(n))

  7. When is equals the case? Can we assign a value to n0? Let n0 be the value where f(n) and g(n) become non-negative When is equals the case?

  8. Informal proof of Q notation If g(n) is dominant term in limit f(n), then f(n) = Q(g(n)) n →∞ Example: Show by informal proof that (n+a)b = Q(nb) real a & b b > 0 Binomial expansion: (n+a)b = Cbnb + Cb-1nb-1+…+C0 Since nb is dominant term at large n, (n+a)b = Q(nb)

  9. Formal proof that (n+a)b = Q(nb) Ex 3.1-2 text p52

  10. a can be < 0 but a < |a| Replacing |a| by something larger strengths inequality Same argument as above Determines n0 Combine 2 inequalities RTA

  11. Floors and Ceilings More properties given on text p54

  12. Show that ceiling of lg(n) = Q(lg(n))

  13. Floors and Ceilings

  14. Little o notation Analogous to a < b for real numbers f(n) = o(g(n)) means f(n) is a member of a set of function such that for any c > 0 (no matter how small) 0 < f(n) < cg(n) all n > n0 Can only be true if f(n) is insignificant relative to g(n) at large n Equivalent to limit f(n)/g(n) = 0 n →∞ g(n) is strictly an asymptotic upper bound on f(n) equality of f(n) and g(n) is excluded 2n = o(n2) 2n2is not o(n2) text p 50

  15. Little omega notation Analogous to a > b for real numbers f(n) = w(g(n)) means f(n) is a member of a set of function such that for any c > 0 (no matter how large) 0 < cg(n) < f(n) all n > n0 Can only be true if g(n) is insignificant relative to f(n) at large n Equivalent to limit g(n)/f(n) = 0 n →∞ g(n) is strictly an asymptotic lower bound on f(n) equality of f(n) and g(n) is excluded n2/2 = w(n) n2/2 is not w(n2) text p51

  16. f(n) = o(g(n)) implies f(n) = O(g(n)) If for any c > 0, 0 < f(n) < cg(n) then there exist some c > 0 such that 0 < f(n) < cg(n) Similarly f(n) = w(g(n)) implies f(n) = W(g(n)) What is wrong with this argument?

  17. Properties of asymptotic notations

  18. Important math from Section 3.2

  19. Asymptotic notation in equations Alone on right side: n = o(n2) set definition Part of an equation: f(n) = 2n2 + Q(n) = Q(n2) In recursive relation T(n) = T(n-1) + Q(n) says overhead is linear Both sides: ΣQ(fk(n)) = Q(Σfk(n)) sum of Qs equals Q of sum

  20. Cpt S 450 Spring 2014 [All problems are from Cormen et al, 3rd Edition] Homework Assignment 2: due 1/29/14 1. Use Stirling’ approximation, Eq(3.18) p 57, to show that n! = o(nn) and n! = w(2n) and to get an informal proof that lg(n!) = Q(nlgn) 2. ex 3.2-7 p 60 3. prob 3-2 p 61

More Related