You are on page 1of 2

MATH 239: Introduction to Combinatorics Fall 2004

Solution to a Problem from the Tutorial


During the tutorial, we discussed the following two problems. When we reviewed the second problem, we
ran into some difficulties. Here we present correct solutions to both problems.

1. Give the generating function for the set S of {0, 1}-strings which do not contain the substring 11.
Solution. This is Problem 1.33 on Page 48 of the course notes. The solution presented there uses the
0-decomposition. We will use the block decomposition here.
To derive a decomposition which uniquely creates the elements of S, we modify the block decompo-
sition:
{0, 1}∗ = {0}∗ ({1}{1}∗ {0}{0}∗ )∗ {1}∗ .
|{z} | {z } | {z } |{z}
A B C D

In each of the four sets, A, B, C, D, we determine which strings we must remove so that the substring
11 is never created:

A: no strings need to be removed.


B: all strings except 1 must be removed.
C: no strings need to be removed.
D: all strings except  and 1 must be removed.

Thus, we see that


S = {0}∗ ({1}{0}{0}∗ )∗ {, 1}.
Using the decomposition, we can compute the generating function:
1 1
ΦS (x) = x (1 + x)
1 − x 1 − x 1−x
1+x
= .
1 − x − x2
This agrees with the solution presented in the course notes.

2. Give the generating function for the set T of {0, 1}-strings which do not contain the substring 11 and
do not begin and end with distinct 1’s (for example, 1, 010, 100, 001 ∈ T but 110, 101 6∈ T ).
Notice that if we take any string in T and bend it into a circle, the substring 11 will never occur.
This is not true of all the strings in S.
We will solve this problem in two different ways.
Solution 1. Notice that T ⊂ S; that is, every string in T is also in S, but there are some strings in
S that are not in T . This suggests that we may be able to determine a decomposition of T of the
form S \ A.
Any string in S that begins and ends with distinct 1’s must be removed. We certainly must remove
all the strings in the set {10}S{01}. Further, if σ ∈ S has length 4 or greater and begins and ends
with distinct 1’s, then σ ∈ {10}S{01}. As for strings of length 3 or less, there is only one such string
in S that must be removed, namely 101. So we see that

T = S \ ({10}S{01} ∪ {101}).

1
Using this decomposition, we can compute ΦT (x) as a function of ΦS (x):

ΦT (x) = ΦS (x) − (x2 ΦS (x)x2 + x3 )


= (1 − x4 )ΦS (x) − x3 .

Now, we substitute in our answer to Problem 1 for ΦS (x):


1+x
ΦT (x) = (1 − x4 ) − x3
1 − x − x2
1 + x − x4 − x5 x3 − x4 − x5
= −
1 − x − x2 1 − x − x2
3
1+x−x
= .
1 − x − x2

Solution 2. Almost all of the strings in T have the form

0σ1 0, 0σ2 01, 10σ3 0

where σ1 , σ2 , σ3 ∈ S. This suggests that we may be able to express T as a union of sets.


Notice that {0}S{0}, {0}S{01}, {10}S{0} are all subsets of T . Further, any string in T that

– begins and ends with 0 and has length at least 2 is in {0}S{0}.


– begins with 0 and ends with 1 and has length at least 3 is in {0}S{01}.
– begins with 1 and ends with 0 and has length at least 3 is in {10}S{0}.

So, we must consider the strings of length 2 or less that are in T but are not contained in any of
{0}S{0}, {0}S{01}, {10}S{0}. The strings we are missing are , 0, 1, 01, 10. Thus, we see that

T = {0}S{0} ∪ {0}S{01} ∪ {10}S{0} ∪ {, 0, 1, 01, 10}.

Using this decomposition, we can compute ΦT (x) as a function of ΦS (x):

ΦT (x) = xΦS (x)x + xΦS (x)x2 + x2 ΦS (x)x + (1 + 2x + 2x2 )


= (x2 + 2x3 )ΦS (x) + 1 + 2x + 2x2 .

Now, we substitute in our answer to Problem 1 for ΦS (x):


1+x
ΦT (x) = (x2 + 2x3 ) + 1 + 2x + 2x2
1 − x − x2
x2 + 3x3 + 2x4 1 + x − x2 − 4x3 − 2x4
= +
1 − x − x2 1 − x − x2
3
1+x−x
= .
1 − x − x2
As it should, this generating function agrees with the one we computed in the previous solution.

You might also like