How many $n$ length vector can be?

34 Views Asked by At

How many $n$ length vector can be where the difference between two adjacent digits is exactly $1$. The digits that can be in the vector are : $0,1,2$.

1

There are 1 best solutions below

0
On BEST ANSWER

Note that the condition implies that the compnents switch parity. As $1$ is the only allowed odd digit, we have to put $1$'s either on all even places or on all odd places. For each of the other places, we have exactly two choices. So if $n=2m$, the answer is $2\cdot 2^m=2^{m+1}$, and if $n=2m+1$, the answer is $2^m+2^{m+1}=3\cdot 2^m$.