Example 8 Using $0,1,2,3,4$ how many $n$-digit numbers can be formed where each pair of adjacent digits differ by exactly 1?
Let the total number of $n$-digit numbers that meet the conditions be $x_{n}$, and the numbers starting with $0,1,2,3,4$ be $y_{n}, z_{n}, u_{n}, v_{n}, w_{n}$ respectively.
Then $x_{n}=y_{n}+z_{n}+u_{n}+v_{n}+w_{n}$.
By symmetry,
$y_{n}=w_{n}, z_{n}=v_{n}$.
Thus, $x_{n}=2 y_{n}+2 z_{n}+u_{n}$.
$1^{\circ}$ When starting with $0,1$, we have $y_{n}=z_{n-1}$.
$2^{\circ}$ When starting with $1,0$ and $1,2$, we have
$$
z_{n}=y_{n-1}+u_{n-1} \text {. }
$$
$3^{\circ}$ When starting with $2,1$ or $2,3$, we have
$$
u_{n}=2 z_{n-1} \text {. }
$$

Thus, we get
$$
z_{n}=z_{n-2}+2 z_{n-2}, z_{1}=1, z_{2}=2 \text {. }
$$

So, $z_{n}=3 z_{n-2}$.
Considering the cases of odd and even separately, we get
$$
\begin{array}{l}
z_{2 n}=3 z_{2 n-2}=3^{2} z_{2 n-4}=\cdots=3^{n-1} z_{2} \\
=2 \cdot 3^{n-1}, \\
z_{2 n-1}=3 z_{2 n-3}=\cdots=3^{n-1} z_{1}=3^{n-1} .
\end{array}
$$

According to $x_{n}=4 z_{n-1}+2 z_{n}$, we get
$$
\begin{array}{l} 
x_{2 n}=2\left(2 \cdot 3^{n-1}\right)+4\left(3^{n-1}\right)=8 \cdot 3^{n-1}, \\
x_{2 n+1}=2 \cdot 3^{n+1}+4 \cdot\left(2 \cdot 3^{n-1}\right)=14 \cdot 3^{n-1} . \\
\left(x_{1}=5\right)
\end{array}
$$