Top Banner
ndix A: Summations vation: Evaluating and/or bounding sums are frequen ed in the solution of recurrences types of evaluation problems: Prove by induction that formula is correct Find the function that the sum equals or is bounde untered both types in analysis of insertion sort
18

Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:

Jan 04, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:

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:

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:

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:

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:

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:
Page 7: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:

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:

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:

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:

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:

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:

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:
Page 14: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:

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:

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:

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:
Page 18: Appendix A: Summations Motivation: Evaluating and/or bounding sums are frequently needed in the solution of recurrences Two types of evaluation problems:

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