Find and solve a recurrence relation for the number of n-digit ternary sequences with no consecutive digits being equal

4.9k Views Asked by At

I had a question that I need some help on:

Find and solve a recurrence relation for the number of n-digit ternary sequences with no consecutive digits being equal

As I worked this out, I realized, I'm not sure what $a_n$ is supposed to be counting. Could someone help me figure out the initial conditions (maybe up to like $a_4$ or something) so I could solve this problem. Please provide a detailed explanation of how you got to those initial conditions so I can better understand the problem. Any hints on how to solve the problem are also encouraged! Thanks in advanced for your help, I really appreciate it!

1

There are 1 best solutions below

3
On

$a_n$ is supposed to be the number of sequences of a, b, and c of length $n$ that don't have a pair of matching consecutive letters. For example, $a_3$ is 12 because there are 12 such sequences of length 3:

aba
abc
aca
acb
bab
bac
bca
bcb
cab
cac
cba
cbc

The recurrence should express $a_{n+1}$ in terms of $a_n$: if you knew how many such sequences there were of length $n$, how can you use that to determine the number of sequences of length $n+1$?

The initial condition would simply be the value of $a_0$ or $a_1$: how many such sequences are there of length 0 or 1?