0% found this document useful (0 votes)
64 views8 pages

Lecture 17 MTL180

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views8 pages

Lecture 17 MTL180

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

MTL180: Discrete Mathematical Structures 1st Semester, 2024-2025

Lecture 17 — 30/09/2024
Lecturer: Prof Minati De Scribe: 17

Scribed by:

1. Daksh Kansil (2023MT61173)

2. Gunveen Gill (2023MT10392)

3. Krish Srivastava (2023MT10252)

4. Keshav Taparia (2023MT60038)

5. Sapna (2023MT10470)

6. Pranika Seenam (2023MT10570)

7. Kedhar Karthik (2023MT10726)

8. Agrim Gupta (2023MT10736)

1 Overview

In the last lecture, we learned about distributing objects into boxes and the recurrence aspect of
permutations and combinations.
In this lecture, we will learn about recurrence relations, and how to apply them in various
problems.

2 Recurrence Relations

Suppose there is a sequence of n terms as follows a0 , a1 , a2 , . . . an .


A recurrence relation is defined as an equation according to which an is equal to some combination
of the previous terms. Often, only k previous terms of the sequence appear in the equation, for a
parameter k that is independent of n; this number is called the order of the relation.

2.1 Fibonacci Sequence:

The Fibonacci Sequence {Fn} is recursively defined as follows

Fn = F n − 1 + Fn−2

with the initial conditions F0 = 1 and F1 = 1

1
2.2 Factorial:

The Factorial n! is explicitly defined as

n! = n ∗ (n − 1) · · · ∗ 1

However, we can also define it recursively by the following relation

n! = n(n − 1)!

with the initial condition 0! = 1.

3 Forming Recurrence Relations

We will now study various problems where we will find the recurrence relation in order to reach
the answer.

Question 1: You have n stairs and n rectangles. In how many ways can you fill the entire
staircase.

Answer:

t0 = 1, t1 = 1, t2 = 2, t3 = 5

Figure 1: Number of ways to fill the entire staircase for n = 0,1,2,3

Figure 2: We Break a staircase of n steps in two parts at the kth step

Then, the tnk for this particular case would be equal to tk−1 tn−k . Therefore,

2
n
X
tn = tk−1 tn−k
k=1

where t0 = 1 and t1 = 1

Question 2: Find the cardinality of power sets using recurrence.

Answer:
S0 = ϕ , S1 = {a1 }, S2 = {a1 , a2 }, ..... , Sn = {a1 , a2 , .... ,an }

P0 = {ϕ}, P1 = {ϕ , {a1 }} , P2 = {ϕ , {a1 }, {a2 }, {a1 , a2 }} , .....

|P0 | = 1, |P1 | = 2, |P2 | = 4,

If Sn = {a1 , a2 , .... ,an }, then all the subsets of Sn , not containing an , would be the same as all
the subsets of Sn−1 . Therefore, the number of these subsets would be equal to the cardinality of
Sn−1 .
All the remaining subsets of Sn would contain an . Each of these subsets would be a union of some
unique subset of Sn−1 and an . Therefore, the number of the remaining subsets would be equal to
the cardinality of Sn−1 .
|Pn | = 2 ∗ |Pn−1 |
|Pn | = 2 ∗ 2 ∗ |Pn−2 | = 22 ∗ |Pn−2 |
|Pn | = 2 ∗ 22 ∗ |Pn−3 | = 23 ∗ |Pn−3 |
.
.
.
.
|Pn | = 2n ∗ |P0 | = 2n

Question 3: Find the number of sequences of upper-case letters that do not contain ”ZZ”.

Answer:
t0 = 1 , t1 = 26 , t2 = 262 −1(number of sequences f rom AA to ZZ = 262 , and we subtract 1 f or ZZ)

Case 1:
When the first letter of the tn sequence is ”Z”, the next letter cannot be ”Z”. There are 25 ways
to achieve this. Since the second letter is not ”Z”, the third letter can be anything. Therefore, the

3
total number of possibilities of the next n - 2 letters is tn−2 . Total number of sequences in this case
is 25 * tn−2 .

Case 2:
When the first letter of the tn sequence is not ”Z”. There are 25 ways to achieve this. Since the
first letter is not ”Z”, the second letter can be anything. Therefore, the total number of possibilities
of the next n - 2 letters is tn−1 . Total number of sequences in this case is 25 * tn−1 .
Therefore, total number of sequences (tn ) = 25 * (tn−1 + tn−2 )

Question 4: Find the number of sequences of upper-case letters that do not contain the substring
”DOG”.

Answer:

Let tn represent the number of valid sequences of length n. We calculate the values as follows:

t0 = 1
t1 = 26
t2 = 262
t3 = 263 − 1(number of sequences f rom AAA to ZZZ = 263 , and we subtract 1 f or DOG)

The recursive relation for general n is:

tn = 26tn−1 − tn−3

Case 1:

If the first letter of the sequence is ’D’, then the next two letters cannot be ’O’ and ’G’. Therefore,
the remaining n − 3 letters form a sequence of length tn−3 .

4
Case 2:

If the first letter is not ’D’, there are 25 choices (since it can be any other letter). The number of
possible sequences for the remaining n − 1 letters is tn−1 .
Thus, the total number of valid sequences is:

tn = 26tn−1 − tn−3

replace DOG with HOE and the string is about me(HOELESS)

Question 5: Number of sequences of A’s, B’s and C’s that contain an odd number of C’s.

Answer:
t0 = 0
t1 = 1
t2 = 4

tn = 2tn−1 + (3n−1 − tn−1 )

Question 6: How many valid ways to arrange “n” pairs of parenthesis?

5
Answer:
t1 = 1
t2 = ( () ) , ( ()() ) , ⇒ 2

n
X
tn = tk tn−k ⇒ Catalan number
k=1
2n

n
Cn = , Cn = Catalan number
n+1

The Tower of Hanoi Puzzle


This classic mathematical puzzle involves three pegs and a set of disks of different sizes. The goal
is to move all the disks from one peg to another peg using an auxiliary peg, following these rules:

1. Only one disk can be moved at a time.

2. A disk can only be placed on top of a larger disk, never on a smaller one.

3. All disks start on one peg in decreasing size (largest at the bottom, smallest at the top).

6
Tower of Hanoi: Recurrence Relation

The Tower of Hanoi problem follows the recurrence relation:

Hn = 2Hn−1 + 1

where Hn represents the minimum number of moves required to transfer n disks from one peg to
another, following the rules of the puzzle. The initial condition is H1 = 1, because one disk can be
moved in a single step.
We can iteratively expand this recurrence relation to obtain:

Hn = 2(2Hn−2 + 1) + 1 = 22 Hn−2 + 2 + 1
= 23 Hn−3 + 22 + 2 + 1
= . . . = 2n−1 H1 + 2n−2 + 2n−3 + · · · + 2 + 1

Since H1 = 1, the relation simplifies to:

Hn = 2n − 1

This gives us the closed form for the recurrence relation.

4 Solving Recurrence Relations

Now we will analyse various techniques to solve recurrence relations.

4.1 Guess and Check

The name for this method is pretty self explanatory. We look at the recurrence relation and try to
guess the answer. Then we check if our guess is consistent with both the initial condition and the
recurrence.

Example: The relation is as follows

hn = 2hn−1 + 1

h1 = 1
We now guess hn to equal 2n − 1.
Putting n = 1 we get h1 = 1.

7
Now, putting hn = 2n − 1 into the equation, we get:

hn = 2(2n−1 − 1) + 1
= 2n − 2 + 1
= 2n − 1

It is clear that both the initial conditions and the equation are consistent. Hence, our guess was
correct.

4.2 Repeated Substitution

In this method, we repeatedly substitute the recurrence relation into itself until we reach the initial
condition. It is easier to illustrate this with an example.

Example: The relation is as follows

tn = 3hn−1 + 7

t0 = 5
Now we will begin substituting the equation into itself.

tn = 3tn−1 + 7
= 3(3tn−2 + 7) + 7
= 32 tn−2 + 3 · 7 + 7
= 33 tn−3 + 32 · 7 + 3 · 7 + 7
= 3k tn−k + 3k−1 · 7 + 3k−2 · 7 + · · · + 3 · 7 + 7

Putting k = n

= 3n t0 + 3n−1 · 7 + 3n−2 · 7 + · · · + 3 · 7 + 7
= 3n · 5 + 7 3n−1 + 3n−2 + · · · + 3 + 1

 n 
n 3 −1
=5·3 +7
2

References

[1] [1] K. H. Rosen, Discrete Mathematics and Its Applications, 7th ed., New York, NY: McGraw-
Hill, 2012

You might also like