Question:
Find the number of ternary sequences (each element of the sequence is $0$, $1$, or $2$) of length $n$ such that $|x_i - x_{i - 1}| = 1$ for each $i$ such that $2 \leq i \leq n$.
My suggestion:
Firstly notice that every second element must be the digit "1".
Lets separate the problem into $2$ classes:
The sequence starts with 1 - The are exactly $\lfloor n/2 \rfloor$ elements that are not "1". For each element we have $2$ possibilities - it's $\lfloor n/2\rfloor^n$
The sequence starts with either 0 or 2 - The are exactly $\lceil n/2 \rceil$ elements that are not "1". For each element we have 2 possibilities - it's $\lceil n/2 \rceil^n$
Sum it up and get:
$2\cdot\lceil n/2 \rceil^n+\lfloor n/2 \rfloor^n$
Is it correct?
Let $a_n,b_n,c_n$ be the number of $n$ lenght sequences which start respectively with 0,1,2.
Then we are interested in $d_n = a_n+b_n+c_n$ and we have $a_n = b_{n-1}$ , $b_n = a_{n-1}+c_{n-1}$ and $c_n = b_{n-1}$. Now solve those recurences and youll get an answer.