Solution (source code)

= Solution

Expand the tridiagonal <determinant> along its first row. The diagonal entry contributes $dD_{N-1}$. In the off-diagonal cofactor, expansion along its first column supplies the other factor $-k$, and the cofactor sign makes the net contribution $-k^2D_{N-2}$. Therefore
$$
\boxed{D_N=dD_{N-1}-k^2D_{N-2},\qquad N\geq2.}
$$
The initial values are $D_1=d$ and $D_2=d^2-k^2$. Writing the same formula at $N=2$ forces $\boxed{D_0=1}$, the empty <determinant> convention. This is the <tridiagonal determinant recurrence>.