diagonal matrix with $k$ 1's and $n-k$ 0's This is from an old qualifying exam. 
Let $V$ be a vector space of dimension $n$ and let $P$ be a projection on $V$ with
$\dim(P(V))=k$. Prove that there is an ordered basis for $V$ such that the matrix representation of $P$ with respect to this basis is a diagonal matrix with $k$ $1$'s and $n-k$ $0$'s on the diagonal.
My solution: Since $P$ is a projection, I can show that the only eigenvalues of 
$P$ are $0$ and $1$. Since $\operatorname{rank}(P)=k$ we have  $\operatorname{nullity}(P)=n-k$. And so the characteristic polynomial of $P$ is $f(x)=x^{n-k}(x-1)^{k}$ <---( Can I immediately say this 
or do I have to prove this fact???). The minimal polynomial $p(x)$ of $P$ must divide $x^2-x$ (because $x^2-x$ annihilates $P$). And so by Cayley Hamilton we must have that $p(x)=x(x-1)$. since $p(x)$ factors completely into distinct linear factors, we must have that $P$ is diagonalizable. And so there exits a basis in which the matrix representation has the desired form.
Is this a good solution?. Is there anything I have to prove more or be more clear :).
Thanks for all your help. 
 A: It is a bit unclear.


*

*"I can show that the only eigenvalues of $P$ are $0$ and $1$." Taking it literally, it means if $P$ has some eigenvalues, they must be either $0$ or $1$. Note that this is different from saying that "$P$ has $n$ eigenvalues and all of them are either $0$ or $1$." You see, when the field is not algebraically closed (e.g. $\mathbb{R}$), some matrices may not even possess a single eigenvalue.

*"And so by Cayley Hamilton ... ." I don't see how Cayley-Hamilton theorem is relevant here. C-H thm says that the minimal polynomial must divide the characteristic polynomial, but here you first establish that $x^2-x$ is an annihilating polynomial, and then argue that the minimal polynomial must divide $x^2-x$. The characteristic polynomial is not used at all.

*"... we must have that p(x)=x(x−1)." Why? $I$ and $0$ are projections, but their minimal polynomials are not $x(x−1)$.


On the whole, I think that the arguments you have shown look quite good. However, since the essential step that $P$ has $n$ eigenvalues in $\{0,1\}$ is not shown, I am not sure if you really have a correct proof.
