Question

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
4.7 (5 ratings)
4.7 (5 ratings)
Step 1
1 of 4

(a) Let ana_n represent the number of ternary strings of length nn that do not contain a pair of consecutive 0's nor a pair of consecutive 1's.

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

Second case \textbf{Second case } For each kk between 0 and n2n-2, there could be string of n1kn-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 2an(nk)=2ak2a_{n-(n-k)}=2a_{k} such strings (aka_k for 0 and aka_k for 1).

Third case\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:

an=an1+2an2+2an3+...+2a0+2a_n=a_{n-1}+2a_{n-2}+2a_{n-3}+...+2a_0+2

Similarly, we also have for n1n-1:

an1=an2+2an3+2an4+...+2a0+2a_{n-1}=a_{n-2}+2a_{n-3}+2a_{n-4}+...+2a_0+2

Subtract the previous two equations:

anan1=an1+an2a_n-a_{n-1}=a_{n-1}+a_{n-2}

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

an=2an1+an2a_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 by Kenneth Rosen

Discrete Mathematics and Its Applications

7th EditionISBN: 9780073383095 (9 more)Kenneth Rosen
4,283 solutions
Discrete Mathematics 8th Edition by Richard Johnsonbaugh

Discrete Mathematics

8th EditionISBN: 9780321964687Richard Johnsonbaugh
4,246 solutions
Discrete Mathematics and Its Applications 8th Edition by Kenneth Rosen

Discrete Mathematics and Its Applications

8th EditionISBN: 9781259676512Kenneth Rosen
4,397 solutions

More related questions

1/4

1/7