Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the...
-
Upload
alberta-fitzgerald -
Category
Documents
-
view
221 -
download
4
Transcript of Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the...
![Page 1: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/1.jpg)
Appendix A: Summations
Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences
Two types of evaluation problems:
Prove by induction that formula is correct
Find the function that the sum equals or is bounded by
Encountered both types in analysis of insertion sort
![Page 2: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/2.jpg)
Prove by induction that j=1 to n j = n(n+1)/2 Called the arithmetic sumText p 1059
![Page 3: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/3.jpg)
Use the arithmetic sum to evaluate the sums in the analysis of insertion sort runtime
![Page 4: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/4.jpg)
Important sums to remember
Arithmetic k=1 to n k = n(n+1)/2 = (n2)
Geometric k=0 to n xk = (xn+1 – 1)/(x – 1) when x 1
Harmonic k=1 to n (1/k) = ln(n) + (1)
![Page 5: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/5.jpg)
Alternate forms of geometric sum useful in tree analysis
k=0 to n-1 xk = (xn – 1)/(x – 1) when x 1
How do we show this is true?
k=0 to ∞ xk = 1/(1 – x)
when |x| < 1
![Page 6: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/6.jpg)
![Page 7: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/7.jpg)
Integration and differentiation can be used to evaluate sums
derivative: d{ f(x)}/dx = df/dx
integral: dx {f(x)} = dx f(x)
Example: eq. A.8 p1148
Show k=0 to ∞ k xk = x/(1 – x)2
when 0< |x| < 1
![Page 8: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/8.jpg)
See bottom p1147 for simpler approach
![Page 9: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/9.jpg)
Bounding sums
Prove a bound by induction
Bound ever term in sum
Bound by integrationmonotone increasing and decreasing summands
![Page 10: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/10.jpg)
Prove by induction on integers that k=0 to n 3k = O(3n)
![Page 11: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/11.jpg)
there exist c=4/3 such that 0<4<3c Similar argument applies n=2, etc.
Property of sums independent of what we are trying to prove
and (1/3 +1/c) < 1, which is true if c > 3/2; therefore, c=3/2 or larger will work in the definition of big OHence k=0 to n 3k = O(3n) by definition
3
Base case n=0 is true
< c3n which implies
![Page 12: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/12.jpg)
Example of bound sum by bounding every term
Show that (n/2)2 < k=1 to n k < n2
![Page 13: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/13.jpg)
![Page 14: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/14.jpg)
Bound by integration: monotone increasing summand
Shaded area is integral ofcontinuous function f(x)
Sum equals area of “upper sum”rectangles
Same f(x) different limits on integration
Sum equals area of “lower sum”rectangles
![Page 15: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/15.jpg)
Note the difference for monotone increasing and decreasing summand
Method not applicable if summand is not monotone increasing or decreasing
![Page 16: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/16.jpg)
Use bounding by integrals for informal proof that k=1 to n k-1 = (ln(n))
![Page 17: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/17.jpg)
![Page 18: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649f1b5503460f94c30a41/html5/thumbnails/18.jpg)
CptS 450 Spring 2015[All problems are from Cormen et al, 3nd Edition]Homework Assignment 3: due 2/4/151. ex A.1-3 p 11492. ex A.1-6 p 11493. ex A.2-1 p 1156 (hint: use integration)4. part a of prop A-1 p 1156 using bound each term