Recurrence Relation for the Number of Bit Strings with Two Consecutive Zeros, Study notes of Linear Algebra

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

Pre 2010

Uploaded on 09/17/2009

koofers-user-a5z-1
koofers-user-a5z-1 ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Jim Lambers
Math 6A
Spring Quarter 2003-04
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 nthat have two consecutive zeros.
Solution Let anbe the number of bit strings of length nthat have two consecutive zeros, where n
is a nonnegative integer. To find a recurrence relation that is satisfied by {an}, we must determine
how ancan be computed if we know anโˆ’1,anโˆ’2and 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 nby 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 nfall into exactly one of four categories:
1. Strings that have two consecutive zeros in their first nโˆ’1 bits, and end with a 0
2. Strings that have two consecutive zeros in their first nโˆ’1 bits, and end with a 1
3. Strings that do not have two consecutive zeros in their first nโˆ’1 bits, and end with a 0
4. Strings that do not have two consecutive zeros in their first nโˆ’1 bits, and end with a 1
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:
1. Strings that have two consecutive zeros in their first nโˆ’1 bits, and end with a 1
2. All strings that end with a 0
The first category contains anโˆ’1strings, because they have two consecutive zeros among their first
nโˆ’1 bits. Therefore, this category contributes anโˆ’1toward an.
The second category must be examined further. We can decompose it into four categories, as
we did before:
1. Strings that have two consecutive zeros in their first nโˆ’2 bits, and end with a 00
2. Strings that have two consecutive zeros in their first nโˆ’2 bits, and end with a 10
3. Strings that do not have two consecutive zeros in their first nโˆ’2 bits, and end with a 00
1
pf2

Partial preview of the text

Download Recurrence Relation for the Number of Bit Strings with Two Consecutive Zeros and more Study notes Linear Algebra in PDF only on Docsity!

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:

  1. Strings that have two consecutive zeros in their first n โˆ’ 1 bits, and end with a 0
  2. Strings that have two consecutive zeros in their first n โˆ’ 1 bits, and end with a 1
  3. Strings that do not have two consecutive zeros in their first n โˆ’ 1 bits, and end with a 0
  4. Strings that do not have two consecutive zeros in their first n โˆ’ 1 bits, and end with a 1

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:

  1. Strings that have two consecutive zeros in their first n โˆ’ 1 bits, and end with a 1
  2. All strings that end with a 0

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:

  1. Strings that have two consecutive zeros in their first n โˆ’ 2 bits, and end with a 00
  2. Strings that have two consecutive zeros in their first n โˆ’ 2 bits, and end with a 10
  3. Strings that do not have two consecutive zeros in their first n โˆ’ 2 bits, and end with a 00
  1. Strings that do not have two consecutive zeros in their first n โˆ’ 2 bits, and end with a 10

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:

  1. Strings that have two consecutive zeros in their first n โˆ’ 2 bits, and end with a 10
  2. All strings that end with a 00

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