1 / 13

CMSC 203 / 0201 Fall 2002

This lecture covers concepts of recurrence relations with examples such as Fibonacci sequence and Tower of Hanoi, along with solutions, initial conditions, and Catalan numbers. Understand fast multiplication algorithms and applications.

mclin
Download Presentation

CMSC 203 / 0201 Fall 2002

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. CMSC 203 / 0201Fall 2002 Week #10 – 28/30 October and 1 November 2002 Prof. Marie desJardins

  2. TOPICS • Recurrence relations and solutions • Divide-and-conquer recurrences

  3. MON 10/28 RECURRENCE RELATIONS (5.1)

  4. Concepts/Vocabulary • Recurrence relations • Solution / solution sequence • Initial conditions • Useful examples: compound interest, bunny rabbits / Fibonacci, Tower of Hanoi, Catalan numbers

  5. Examples • Exercise 5.1.4: For each of the following sequences, find a recurrence relation satisfied by this sequence: • (b) an = 2n • (d) an = 5n • (f) an = n2 + n • (g) an = n + (-1)n

  6. Examples II • Save early and often: Exercise 5.1.6: A person deposits $1000 in an account that yields 9% interest compounded yearly. • (a) Set up a recurrence relation for the amount in the acount at the end of n years. • (b) Find an explicit formula for the amount in the account at the end of n years. • (c) How much money will the account contain after 100 years?

  7. Examples III • Exercise 5.1.11: Use mathematical induction to verify the formula derived in Example 5 for the number of moves required to complete the Tower of Hanoi puzzle: • Hn = 2n - 1 • Catalan numbers: Example 5.1.8 (p. 315): Find a recurrence relation for Cn, the number of ways to parenthesize the product of n+1 numbers, x0x1…xn. • Cn = k=0n-1 Ck Cn-k-1 • C0 = C1 = 1

  8. Examples IV • Exercise 5.23: A ternary string contains only 0s, 1s, and 2s. • (a) Find a recurrence relation for the number of ternary strings that do not contain two consecutive 0s. • (b) What are the initial conditions? • (c) How many ternary strings of length six do not contain two consecutive 0s? • Exercise 5.25: • (a) Find a recurrence relation for the number of ternary strings that do not contain two consecutive 0s or two consecutive 1s. • (b) What are the initial conditions? • (c) How many ternary strings of length six do not contain two consecutive 0s or two consecutive ones?

  9. WED 10/30 - FRI 11/1DIVIDE-AND-CONQUER (5.3) ** HOMEWORK #7 DUE ** ** FEEDBACK SESSION TODAY **

  10. Concepts / Vocabulary • Divide-and-conquer recurrence relations • f(n) = a f(n/b) + g(n)

  11. Examples • Exercise 5.3.7: Suppose that f(n) = f(n/3) + 1 when n is divisible by 3, and f(1) = 1. Find • (a) f(3) • (b) f(27) • (c) f(729) = f(36) • Fast multiplication (Example 5.3.3, p. 333) • ab = (22n + 2n) A1B1 + 2n(A1-A0)(B0-B1) + (2n+1)A0B0 • Exercise 5.3.3: Multiply (1110)2 and (1010)2 using the fast multiplication algorithm. • Exercise 5.3.4: Express the fast multiplication algorithm in pseudocode.

  12. Examples II • Exercises 5.3.14-16: • Suppose that there are n = 2k teams in an elimination tournament, where there are n/2 games in the first round, with the n/2 = 2k-1 winners playing in the second round, and so on. Develop a recurrence relation for the number of rounds in the tournament. • How many rounds are there when there are 32 teams? • Solve the recurrence relation for the number of rounds in the tournament.

  13. Examples III • Theorem 1: for a recurrence relation f(n) = a f(n/b) + cwhenever b|n, a1, integer b>1, and real c>0, f(n) = O(nlogba) if a > 1 and f(n) = O(log n) if a=1.

More Related