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

Post on 04-Jan-2016

216 Views

Category:

Documents

4 Downloads

Preview:

Click to see full reader

Transcript

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

Prove by induction that j=1 to n j = n(n+1)/2 Called the arithmetic sumText p 1059

Use the arithmetic sum to evaluate the sums in the analysis of insertion sort runtime

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)

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

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

See bottom p1147 for simpler approach

Bounding sums

Prove a bound by induction

Bound ever term in sum

Bound by integrationmonotone increasing and decreasing summands

Prove by induction on integers that k=0 to n 3k = O(3n)

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

Example of bound sum by bounding every term

Show that (n/2)2 < k=1 to n k < n2

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

Note the difference for monotone increasing and decreasing summand

Method not applicable if summand is not monotone increasing or decreasing

Use bounding by integrals for informal proof that k=1 to n k-1 = (ln(n))

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

top related