Assume the tridiagonal matrix $T$ is in this form:
$$ T = \begin{bmatrix} a & c & & & &\\ b & a & c & & &\\ & b & a & c & &\\ & & &\ddots & &\\ & & & b & a & c\\ & & & & b & a\\ \end{bmatrix} $$
we must show that its eigenvalues are of the form
$$a + 2 \sqrt{bc} \, \cos \left( \frac{k \pi}{n+1} \right)$$
where $$a=qh^2−1, ~~ b=1- \frac{ph}{2}, ~~ c =1+\frac{ph}{2} , ~~q \leq 0.$$
Consider the matrix $S$ which is equal to $T$ except that the diagonal is zero. That is, $T=a I + S$. If we knew the eigenvalues $\lambda_1,\ldots,\lambda_n$ of $S$, the eigenvalues of $T$ are simply $a+\lambda_1,\ldots,a+\lambda_n$.
Now let $$ D=\mathrm{diag}(\delta_1,\ldots,\delta_n), \quad \delta_i=\left(\frac{b}{c}\right)^{\frac{i-1}{2}}, $$ and notice that the matrix $P=D^{-1}SD$ is symmetric. Indeed, $$ p_{i+1,i}=\delta_{i+1}^{-1}b\delta_i=b\left(\frac{b}{c}\right)^{\frac{i}{2}+\frac{i-1}{2}}=\sqrt{bc}, \quad p_{i,i+1}=\delta_i^{-1}c\delta_{i+1}=\cdots=\sqrt{bc}. $$ Hence $$ T=\alpha I + S \sim \alpha I + P = \alpha I + \sqrt{bc} Q, $$ where $Q$ is zero everywhere except the ones in above and below the main diagonal and hence the eigenvalues of $T$ are $\alpha+\sqrt{bc}\mu$, where $\mu$ is an eigenvalue of $Q$.
Now assume that a vector $v=(v_i)$ is an eigenvector of $Q$ associated with the eigenvalue $\mu$. We have $$\tag{1} v_{i-1}+v_{i+1}=\mu v_i, \quad i=2,\ldots,n-1, \quad v_2 = \mu v_1, \quad v_{n-1} = \mu v_n. $$ Assume $v_i$ in the form $v_i=\alpha\sin i\theta+\beta\cos i\theta$. We have $$ \begin{split} v_{i-1}+v_{i+1} &= \alpha[\sin(i-1)\theta+\sin(i+1)\theta]+\beta[\cos(i-1)\theta+\cos(i+1)\theta] \\&= \alpha[\sin i\theta\cos\theta-\cos i\theta\sin\theta+\sin i\theta\cos\theta+\cos i\theta\sin\theta] \\&+ \beta[\cos i\theta\cos\theta+\sin i\theta\sin\theta+\cos i\theta\cos\theta-\sin i\theta\sin\theta] \\&= 2\alpha\sin i\theta\cos\theta + 2\beta\cos i\theta\cos\theta =2\cos\theta v_i. \end{split} $$ This yields $\mu=2\cos\theta$. It remains to find $\theta$; for this we use the boundary conditions in (1). So with $v_i=\alpha\sin\theta+\beta\cos\theta$, $$ v_2=\mu v_1\quad\Leftrightarrow\quad \alpha\sin 2\theta+\beta\cos 2\theta=2\cos\theta(\alpha\sin\theta+\beta\cos\theta), $$ $$ v_{n-1}=\mu v_n\quad\Leftrightarrow\alpha\sin(n-1)\theta+\beta\cos(n-1)\theta=2\cos\theta(\alpha\sin n\theta+\beta\cos n\theta). $$ This gives a system for $\alpha$ and $\beta$: $$ A\begin{bmatrix}\alpha\\\beta\end{bmatrix}=0, $$ where $$ \begin{split} A&=\begin{bmatrix} \sin 2\theta-2\sin\theta\cos\theta&\cos 2\theta-2\cos^2\theta\\ \sin(n-1)\theta-2\sin n\theta\cos\theta&\cos(n-1)\theta-2\cos n\theta\cos\theta \end{bmatrix} \\&= \begin{bmatrix} 0 & -1 \\ -\sin(n+1)\theta & * \end{bmatrix}. \end{split} $$ The first equation gives $\beta=0$. We look for a nonzero $\alpha$; for this we must have $\sin(n+1)\theta=0$. This gives $$ \theta:=\theta_k=\frac{k\pi}{n+1}, \quad \mu_k=2\cos\frac{k\pi}{n+1}. $$ Hence the eigenvalues of $T$ are $$ a+\sqrt{bc}\mu_k=a+2\sqrt{bc}\cos\frac{k\pi}{n+1}, \quad k = 1,\ldots,n. $$