1 / 16

CS 173: Discrete Mathematical Structures

CS 173: Discrete Mathematical Structures. Cinda Heeren heeren@cs.uiuc.edu Siebel Center, rm 2213 Office Hours: W 12:30-2:30. CS 173 Announcements. Homework #10 available, due 11/20, 8a. CS 173 Recurrences. Linear NONhomogeneous recurrence relations with constant coefficients.

chuong
Télécharger la présentation

CS 173: Discrete Mathematical Structures

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. CS 173:Discrete Mathematical Structures Cinda Heeren heeren@cs.uiuc.edu Siebel Center, rm 2213 Office Hours: W 12:30-2:30

  2. CS 173 Announcements • Homework #10 available, due 11/20, 8a. Cs173 - Spring 2004

  3. CS 173 Recurrences Linear NONhomogeneous recurrence relations with constant coefficients. c0an + c1an-1 + c2an-2 + … + ckan-k = f(n), • constant • polynomial in n • cn for some constant c • cn · polynomial(n) Where f(n) is This is approach is different than the one in your text. Easier and more general. Cs173 - Spring 2004

  4. (E-1) “annihilates” c CS 173 Recurrences Example: solve an = 5an-1 - 6an-2 + 4 • Rewrite: an - 5an-1 + 6an-2 = 4 • Rewrite again so n is smallest index: an+2 - 5an+1 + 6an = 4 • Rewrite again as a sequence: an+2 - 5an+1 + 6an = 4 • Rewrite again using operators: (E2 - 5E + 6)an = 4 Cs173 - Spring 2004

  5. (E-1) “annihilates” c Homogeneous!!! CS 173 Recurrences Example: solve an = 5an-1 - 6an-2 + 4 (E2 - 5E + 6)an = 4 • Annihilate right side: (E-1)(E2 - 5E + 6)an = (E-1)4 (E3 - 6E2 + 11E - 6)an = 0 • But that’s just: an+3 - 6an+2 + 11an+1 - 6an = 0 an - 6an-1 + 11an-2 - 6an-3 = 0 Cs173 - Spring 2004

  6. Homogeneous!!! CS 173 Recurrences Example: solve an - 6an-1 + 11an-2 - 6an-3 = 0 • Characteristic equation: (r3 - 6r2 + 11r - 6) = 0 (r-1)(r-2)(r-3) = 0 • General solution: an = A1 + A22n + A33n • Not a coincidence that characteristic equation looks the same as the annihilating operator: f(r)=0 corresponds exactly to g(E)an = 0 Cs173 - Spring 2004

  7. How? CS 173 Recurrences Technique: • Rewrite recurrence in sequence notation. • Rewrite left side as OPan. • Find an annihilator for sequence on right side and apply to both sides • Read characteristic equation off left side. • Solve homogeneous equation as before. Cs173 - Spring 2004

  8. Use operator (E - 1) “Discrete derivative” CS 173 Recurrences So far we know how to annihilate c for constant c. Linear NONhomogeneous recurrence relations with constant coefficients. c0an + c1an-1 + c2an-2 + … + ckan-k = f(n), • constant • polynomial in n • cn for some constant c • cn · polynomial(n) Where f(n) is Cs173 - Spring 2004

  9. Use operator (E - 1) “Discrete derivative” (E - 1)an = Ean - an = an+1 - an = an+1 - an CS 173 Recurrences Group challenge: find the annihilators for the remaining function types. Linear NONhomogeneous recurrence relations with constant coefficients. c0an + c1an-1 + c2an-2 + … + ckan-k = f(n), • constant • polynomial in n • cn for some constant c • cn · polynomial(n) Where f(n) is Cs173 - Spring 2004

  10. Use operator (E - 1) “Discrete derivative” (E - 1)an = Ean - an = an+1 - an = an+1 - an Annihilator: (E - 1)k+1 CS 173 Recurrences Group challenge: find the annihilators for the remaining function types. Linear NONhomogeneous recurrence relations with constant coefficients. c0an + c1an-1 + c2an-2 + … + ckan-k = f(n), • constant • polynomial in n of degree k Where f(n) is Cs173 - Spring 2004

  11. CS 173 Recurrences How do you annihilate cn? Consider 3n: E3n = 33n = 3, 9, 27, … 3, 9, 27, … So (E-3)3n = 0 In general (E-c) annihilates cn Cs173 - Spring 2004

  12. CS 173 Recurrences Table of handy annihilators: Sequence Annihilator Cs173 - Spring 2004

  13. CS 173 Recurrences Another little helpful fact: Suppose operator A annihilates an And B annihilates bn Then AB annihilates an +bn Cs173 - Spring 2004

  14. CS 173 Recurrences Solve an = 2an-1 + 2n - 1, a0 = 0. Rewrite as sequences: an - 2an-1 = 2n - 1 an+1 - 2an = 2n+1 - 1 Rewrite using operators: (E-2)an = 2n+1 - 1 Rewrite right side as sum: (E-2)an = 2n+1 - 1 Apply annihilators to both sides: (E-2)(E-1)(E-2)an = (E-2)(E-1) (2n+1 - 1) =0 Write down general soln: an = (A1 + A2n)2n + A3 Cs173 - Spring 2004

  15. an = (n - 1)2n + 1 CS 173 Recurrences Solve an = 2an-1 + 2n - 1, a0 = 0. General solution: an = (A1 + A2n)2n + A3 Need 3 initial values because we have 3 unknowns to solve for. A1 = 2(0) + 21 - 1 = 1, A2 = 2(1) + 22 - 1 = 5 Solve 3 equations in 3 unknowns (using the general solution): A1 + A3 = 0 2A1 + 2A2 + A3 = 1 4A1 + 8A2 + A3 = 1 A1 = -1, A2 = A3 = 1 Cs173 - Spring 2004

  16. Mergesort # of comparisons CS 173 Recurrences Solve an = 2an/2 + n-1, a1 = 0. Cs173 - Spring 2004

More Related