Lec 08 z Recurrence
Lec 08 z Recurrence
LECTURE 8: RECURRENCES
Rosen 5th ed., §6.1 – 6.3
RECURRENCE RELATIONS
¢ Some of the counting problems that cannot be
solved using the techniques discussed in Chapter
4 can be solved by finding relationships, called
recurrence relations, between the terms of a
sequence.
¢ We will study a variety of counting problems that
can be modeled using recurrence relations.
1
LEARNING OUTCOMES
¢ Solve problems using recurrence relations.
¢ Define appropriate recurrence relations for a
given problem.
¢ Solve linear recurrence relations by recognizing
homogeneity, linearity, constant coefficients,
degree, and characteristic equation.
¢ Design recurrence relations using the divide-and-
conquer algorithm.
(#)
BOOK EX-3: COMPOUND INTEREST
¢ Suppose that a person deposits $10,000 in a savings
account at a bank yielding 11% per year with interest
compounded annually. How much will be in the account
after 30 years?
Solution:
¢ To solve this problem, let Pn denote the amount in the
account after n years. Since the amount in the account
after n years equals the amount in the account after n- 1
years plus interest for the nth year, we see that the
sequence {Pn} satisfies the recurrence relation
2
BOOK EX-4: RABBITS AND THE FIBONACCI
NUMBERS
¢ A young pair of rabbits (one of each sex) is placed
on an island. A pair of rabbits does not breed
until they are 2 months old. After they are 2
months old, each pair of rabbits produces another
pair each month, as shown in Figure 1. Find a
recurrence relation for the number of pairs of
rabbits on the island after n months, assuming
that no rabbits ever die.
3
BOOK EX-4: RABBITS AND THE FIBONACCI
NUMBERS
4
EX: PARANTHESIS OF MULTIPLICATION
5
EX: BIT STRINGS OF LENGTH N THAT DO NOT HAVE
TWO CONSECUTIVE 0’S
sn = sn-1 + sn-2
s1 = 2
s2 = 3 6
LINEAR HOMOGENEOUS RECURRENCE
RELATIONS WITH CONSTANT COEFFICIENTS
a2 = 5
Given any k consecutive values, a
a3 = 5(5) - 6(1) = 19 unique solution exists.
a4 = … 7
THEOREM
Example continued:
T(n) = 7T(n-1) - 10T(n-2)
T(0) = 2, T(1) = 1
α 12 0 + α 25 0 = 2 α 1+ α 2 = 2 α1= 3, α2 = -1
α 12 1 + α 25 1 = 1 2α1 + 5α2 = 1
Rewrite:
Find characteristic eqn:
Find roots of char eqn:
General solution is
Set up system of eqn to get unique soln.
11
BOOK EXAMPLE-6
12
EXERCISE
13
LINEAR NON-HOMOGENEOUS RECURRENCE
RELATIONS
constant
Where f(n) is
polynomial in n
cn for some constant c
cn · polynomial(n)
14
BOOK EX-10
¢ Find all solutions of the recurrence relation
an = 3an-1 + 2n. What is the solution with a1 =3?
16
BOOK EX-11
¢ Find all solutions of the recurrence relation
n
an = 5an -1 - 6an - 2 + 7
17
SEQUENCES
Sequence operators:
Constant multiplication
c·áanñ defined to be ác·anñ
Ex: 3·á2nñ = á3·2nñ = 3, 6, 12, 24, 48, …
Shift “E”
Eáanñ = áan+1ñ shifts the sequence
Ex: Eá2nñ = á2n+1ñ = 2, 4, 8, 16, …
Ex: Eá3n + 1ñ = á3(n+1) + 1ñ = á3n + 4ñ
19
SEQUENCES
Combining operators:
22
EXAMPLE
Characteristic equation:
(r3 - 6r2 + 11r - 6) = 0
(r-1)(r-2)(r-3) = 0
25