10 (15 points) Given that $p, q (q \neq 0)$ are real numbers, the equation $x^{2}-p x+q=0$ has two real roots $\alpha, \beta$, and the sequence $\left\{a_{n}\right\}$ satisfies $a_{1}=p, a_{2}=p^{2}-q, a_{n}=p a_{n-1}-q a_{n-2}$ $(n=3,4, \cdots)$
(1) Find the general term formula of the sequence $\left\{a_{n}\right\}$ (expressed in terms of $\alpha, \beta$);
(2) If $p=1, q=\frac{1}{4}$, find the sum of the first $n$ terms of $\left\{a_{n}\right\}$.
(10) Method 1: (1) By Vieta's formulas, we know $\alpha \cdot \beta=q \neq 0$, and $\alpha+\beta=p$, so
$$
\begin{aligned}
a_{n} & =p x_{n-1}-q x_{n-2} \\
& =(\alpha+\beta) a_{n-1}-\alpha \beta a_{n-2}(n=3,4,5, \cdots)
\end{aligned}
$$

Rearranging gives
$$
a_{n}-\beta a_{n-1}=\alpha\left(a_{n-1}-\beta a_{n-2}\right) .
$$

Let $b_{n}=a_{n+1}-\beta a_{n}$, then $b_{n+1}=\alpha b_{n}(n=1,2, \cdots)$. Therefore, $\left\{b_{n}\right\}$ is a geometric sequence with a common ratio of $\alpha$.
The first term of the sequence $\left\{b_{n}\right\}$ is
$$
b_{1}=a_{2}-\beta a_{1}=p^{2}-q-\beta p=(\alpha+\beta)^{2}-\alpha \beta-\beta(\alpha+\beta)=\alpha^{2} \text {. }
$$

So $b_{n}=\alpha^{2} \cdot \alpha^{n-1}=\alpha^{n+1}$, i.e., $a_{n+1}-\beta a_{n}=\alpha^{n+1}(n=1,2, \cdots)$.
Thus, $a_{n+1}=\beta a_{n}+\alpha^{n+1}(n=1,2, \cdots)$.
When $\Delta=p^{2}-4 q=0$, $\alpha=\beta \neq 0, a_{1}=p=\alpha+\alpha=2 \alpha, a_{n+1}=$ $\beta a_{n}+\alpha^{n+1}(n=1,2, \cdots)$ becomes $a_{n+1}=\alpha a_{n}+\alpha^{n+1}(n=1,2, \cdots)$. Rearranging gives $\frac{a_{n+1}}{\alpha^{n+1}}-\frac{a_{n}}{\alpha^{n}}=1(n=1,2, \cdots)$. Therefore, the sequence $\left\{\frac{a_{n}}{\alpha^{n}}\right\}$ is an arithmetic sequence with a common difference of 1, and its first term is $\frac{a_{1}}{\alpha}=\frac{2 \alpha}{\alpha}=2$. So
$$
\frac{a_{n}}{\alpha^{n}}=2+1(n-1)=n+1 .
$$

Thus, the general term formula for the sequence $\left\{a_{n}\right\}$ is
$$
a_{n}=(n+1) \alpha^{n} .
$$

When $\Delta=p^{2}-4 q>0$, $\alpha \neq \beta$,
$$
\begin{aligned}
a_{n+1} & =\beta a_{n}+\alpha^{n+1} \\
& =\beta a_{n}+\frac{\beta-\alpha}{\beta-\alpha} \alpha^{n+1} \\
& =\beta a_{n}+\frac{\beta}{\beta-\alpha} \alpha^{n+1}-\frac{\alpha}{\beta-\alpha} \alpha^{n+1}(n=1,2, \cdots) .
\end{aligned}
$$

Rearranging gives
$$
a_{n+1}+\frac{\alpha^{n+2}}{\beta-\alpha}=\beta\left(a_{n}+\frac{\alpha^{n+1}}{\beta-\alpha}\right)(n=1,2, \cdots) .
$$

Therefore, the sequence $\left\{a_{n}+\frac{\alpha^{n+1}}{\beta-\alpha}\right\}$ is a geometric sequence with a common ratio of $\beta$, and its first term is
$$
a_{1}+\frac{\alpha^{2}}{\beta-\alpha}=\alpha+\beta+\frac{\alpha^{2}}{\beta-\alpha}=\frac{\beta^{2}}{\beta-\alpha} .
$$

So
$$
a_{n}+\frac{\alpha^{n+1}}{\beta-\alpha}=\frac{\beta^{2}}{\beta-\alpha} \beta^{n-1} .
$$

Thus, the general term formula for the sequence $\left\{a_{n}\right\}$ is
$$
a_{n}=\frac{\beta^{n+1}-\alpha^{n+1}}{\beta-\alpha} .
$$
(2) If $p=1, q=\frac{1}{4}$, then $\Delta=p^{2}-4 q=0$, at this time $\alpha=\beta=\frac{1}{2}$. By the result of step (1), the general term formula for the sequence $\left\{a_{n}\right\}$ is
$$
a_{n}=(n+1)\left(\frac{1}{2}\right)^{n}=\frac{n+1}{2^{n}},
$$

So, the sum of the first $n$ terms of $\left\{a_{n}\right\}$ is
$$
\begin{array}{c}
S_{n}=\frac{2}{2}+\frac{3}{2^{2}}+\frac{4}{2^{3}}+\cdots+\frac{n}{2^{n-1}}+\frac{n+1}{2^{n}}, \\
\frac{1}{2} S_{n}=\frac{2}{2^{2}}+\frac{3}{2^{3}}+\frac{4}{2^{4}}+\cdots+\frac{n}{2^{n}}+\frac{n+1}{2^{n+1}},
\end{array}
$$

Subtracting the above two equations and rearranging gives
$$
\frac{1}{2} S_{n}=\frac{3}{2}-\frac{n+3}{2^{n+1}}
$$

So $S_{n}=3-\frac{n+3}{2^{n}}$.
Method 2: (1) By Vieta's formulas, we know $\alpha \cdot \beta=q \neq 0$, and $\alpha+\beta=p$, so
$$
a_{1}=\alpha+\beta, a_{2}=\alpha^{2}+\beta^{2}+\alpha \beta .
$$

The characteristic equation $\lambda^{2}-p \lambda+q=0$ has two roots $\alpha, \beta$.
When $\alpha=\beta \neq 0$, the general term is $a_{n}=\left(A_{1}+A_{2} n\right) \alpha^{n}(n=1,2, \cdots)$, and from $a_{1}=2 \alpha, a_{2}=3 \alpha^{2}$ we get
$$
\left\{\begin{array}{l}
\left(A_{1}+A_{2}\right) \alpha=2 \alpha, \\
\left(A_{1}+2 A_{2}\right) \alpha^{2}=3 \alpha^{2},
\end{array}\right.
$$

Solving gives $A_{1}=A_{2}=1$. Hence
$$
a_{n}=(1+n) \alpha^{n} \text {. }
$$

When $\alpha \neq \beta$, the general term is $a_{n}=A_{1} \alpha^{n}+A_{2} \beta^{n}(n=1,2, \cdots)$. From $a_{1}=$ $\alpha+\beta, a_{2}=\alpha^{2}+\beta^{2}+\alpha \beta$ we get
$$
\left\{\begin{array}{l}
A_{1} \alpha+A_{2} \beta=\alpha+\beta, \\
A_{1} \alpha^{2}+A_{2} \beta^{2}=\alpha^{2}+\beta^{2}+\alpha \beta,
\end{array}\right.
$$

Solving gives $A_{1}=\frac{-\alpha}{\beta-\alpha}, A_{2}=\frac{\beta}{\beta-\alpha}$. Hence
$$
a_{n}=\frac{-\alpha^{n+1}}{\beta-\alpha}+\frac{\beta^{n+1}}{\beta-\alpha}=\frac{\beta^{n+1}-\alpha^{n+1}}{\beta-\alpha} .
$$
(2) Same as Method 1.