Let
and let
be the set of all strings of length zero or more that can be made using each of the elements of
zero or more times. By the generalized rule of products, there are
such strings that have length
Suppose that
is the set of strings of length
with the property that all of the
’s and
’s precede all of the
’s,
’s, and
’s. Thus
but
Let
A closed form expression for
can be obtained by recognizing
as the convolution of two sequences. To illustrate our point, we will consider the calculation of
Note that if a string belongs to it starts with characters from and is followed by characters from Let be the number of strings of ’s and ’s with length and let be the number of strings of ’s, ’s, and ’s with length By the generalized rule of products, and Among the strings in are the ones that start with two ’s and ’s and end with ’s, ’s, and ’s. There are such strings. By the law of addition,
Note that the sixth term of R is the sixth term of the convolution of with Think about the general situation for a while and it should be clear that Now, our course of action will be to:
-
Determine the generating functions of
and
-
Multiply
and
to obtain
and
-
Determine
on the basis of
-
-
-
To recognize from we must do a partial fractions decomposition:
Therefore, and The solution of this pair of equations is and Since which is the sum of the generating functions of and
For example,
Naturally, this equals the sum that we get from
To put this number in perspective, the total number of strings of length 6 with no restrictions is
and
Therefore approximately 13 percent of the strings of length 6 satisfy the conditions of the problem.