## Related questions with answers

a) Find a recurrence relation for the number of ternary strings of length n that do not contain two consecutive 0s or two consecutive 1s. b) What are the initial conditions? c) How many ternary strings of length six do not contain two consecutive 0s or two consecutive 1s?

Solution

Verified(a) Let $a_n$ represent the number of ternary strings of length $n$ that do not contain a pair of consecutive 0's nor a pair of consecutive 1's.

$\textbf{First case }$ If the ternary string starts with a $2$, then the ternary string of length $n-1$ (ignore the first 2) can start with a 0, 1 or 2 and thus there are $a_{n-1}$ such strings starting with a 2 followed by strings of length $n-1$.

$\textbf{Second case }$ For each $k$ between 0 and $n-2$, there could be string of $n-1-k$ alternating 0's and 1's which is followed by a 2 and then followed by no pair of consecutive 0's nor 1's, while there are then $2a_{n-(n-k)}=2a_{k}$ such strings ($a_k$ for 0 and $a_k$ for 1).

$\textbf{Third case}$ The ternary string contains no 2's and thus contains only alternating 0's and 1's. There are 2 such possible strings (one starting with 0 and one starting with 1).

Adding the number of sequences of all three cases, we then obtain:

$a_n=a_{n-1}+2a_{n-2}+2a_{n-3}+...+2a_0+2$

Similarly, we also have for $n-1$:

$a_{n-1}=a_{n-2}+2a_{n-3}+2a_{n-4}+...+2a_0+2$

Subtract the previous two equations:

$a_n-a_{n-1}=a_{n-1}+a_{n-2}$

Add $a_{n-1}$ to each side of the previous equation:

$a_n=2a_{n-1}+a_{n-2}$

## Create an account to view solutions

## Create an account to view solutions

## Recommended textbook solutions

#### Discrete Mathematics and Its Applications

7th Edition•ISBN: 9780073383095 (9 more)Kenneth Rosen#### Advanced Mathematics: Precalculus with Discrete Mathematics and Data Analysis

ISBN: 9780395551899Brown#### Discrete Mathematics and Its Applications

8th Edition•ISBN: 9781259676512Kenneth Rosen## More related questions

- chemistry

1/4

- chemistry

1/7