

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A solution to exercise 23(a) in section 6.1 of math 6a, spring quarter 2003-04. The problem asks to find a recurrence relation that describes the number of bit strings of length n having two consecutive zeros. The solution is presented step by step, analyzing how bit strings of length n can be obtained from strings of shorter length. The document concludes with the derived recurrence relation: an = an-1 + an-2 + 2n-2.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Jim Lambers Math 6A Spring Quarter 2003- Lecture 22 Examples
This example corresponds to Section 6.1 in the text.
Example (Exercise 23(a), Section 6.1) Find a recurrence relation that describes the number of bit strings of length n that have two consecutive zeros.
Solution Let an be the number of bit strings of length n that have two consecutive zeros, where n is a nonnegative integer. To find a recurrence relation that is satisfied by {an}, we must determine how an can be computed if we know anโ 1 , anโ 2 and so on. This is equivalent to determining how bit strings of length n, that have two consecutive zeros, can be obtained from strings of shorter length. A bit string of length n โ 1 is extended to a bit string of length n by adding a 0 or a 1. Furthermore, such a bit string of length n โ 1 may, or may not, have two consecutive zeros. It follows that all bit strings of length n fall into exactly one of four categories:
Strings in the fourth category cannot have two consecutive zeros, so we do not need to consider them. The remaining strings can be described using ony two categories:
The first category contains anโ 1 strings, because they have two consecutive zeros among their first n โ 1 bits. Therefore, this category contributes anโ 1 toward an. The second category must be examined further. We can decompose it into four categories, as we did before:
As before, strings in the fourth category cannot have two consecutive zeros, so we do not need to consider them. The remaining strings can be described using ony two categories:
The first category contains anโ 2 strings, because they have two consecutive zeros among their first nโ2 bits. Therefore, this category contributes anโ 2 toward an. Every string in the second category has two consecutive zeros, because they have been added to the end. Since the first n โ 2 bits are arbitrary, and the last two bits must be 0โs, it follows that the number of strings in this category is equal to the total number of bit strings of length n โ 2, which is 2nโ^2. Combining the contributions from all categories, we obtain the recurrence relation
an = anโ 1 + anโ 2 + 2nโ^2.
This example serves as an illustration of how to model functions using recurrence relations. When trying to count the number of objects in a set S(n) that depends on some integer n, several cases must be considered in order to determine how S(n) depends on S(n โ 1), S(n โ 2), and so on. One must ensure that all cases that are considered are mutually exclusive, and that they take into account all relevant possibilities. This can usually be accomplished by considering subsets that have or do not have a certain property, since any element must belong to exactly one such subset. 2