CMSC 203 / 0201 Fall 2002 - PowerPoint PPT Presentation

About This Presentation
Title:

CMSC 203 / 0201 Fall 2002

Description:

Exercise 5.1.4: For each of the following sequences, find a recurrence relation ... Exercise 5.25: ... ab = (22n 2n) A1B1 2n(A1-A0)(B0-B1) (2n 1)A0B0 ... – PowerPoint PPT presentation

Number of Views:166
Avg rating:3.0/5.0
Slides: 14
Provided by: Mariedes8
Category:
Tags: cmsc | fall

less

Transcript and Presenter's Notes

Title: CMSC 203 / 0201 Fall 2002


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 n1 numbers,
    x0?x1??xn.
  • Cn ?k0n-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)
    (2n1)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 bn, a?1, integer bgt1, and
    real cgt0, f(n) O(nlogba) if a gt 1 and f(n)
    O(log n) if a1.
Write a Comment
User Comments (0)
About PowerShow.com