I know that the possible eigenvalues of an idempotent or involutory matrix are $0$, $1$ and $-1$, $1$ respectively.
My question is: can I extend this condition as both necessary and sufficient condition?
That is, can I say that if a matrix has only $0$ or $1$ ($-1$ and $1$) as its eigenvalues then the matrix is idempotent (involutory)?
If not please supply a counter example.
Another necessary condition has to be stated that a matrix has a basis of eigenvectors, which is equivalent to saying it is diagonalizable. Without it, a matrix such as
$$A = \begin{pmatrix}1 & 1 \\ 0 & 1\end{pmatrix}$$
provides a counterexample: it's only eigenvalue is $1$, but it is neither involutary nor idempotent:
$$A^2 = \begin{pmatrix}1 & 2 \\ 0 & 1\end{pmatrix}$$
If, however, a matrix is diagonalizable, and all eigenvalues are $0$ and $1$, then in eivenvector basis it looks like
$$\begin{pmatrix} 1 & 0 & 0 & \dots & 0 \\ 0 & 0 & 0 & \dots & 0 \\ 0 & 0 & 1 & \dots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \dots & 0 \end{pmatrix}$$
with only $1$s and $0$s on the diagonal, so it is clearly idempotent.
A similar argument holds for $\lambda \in \{-1,1\}$ and involutary matrices.