How to find Basis of vector space of real $n \times n$ matrices $V$ is vector space of real $n \times n$ matrices and $W$ is a set of elements of $A$ with trace equal to zero.  How can we find the basis of $W$?
I have seen a few questions previously posted including one that was identical with the exception that it considered only $2 \times 2$ matrices. 
I have tried to use the logic derived from them and worked out the following solution: 
The dimension of the basis of $W$ will be $n-1$. The basis will have $n \times n$ matrices of form 
Mi  = { a11 = 1, all elements except  ai +1 i + 1 =0, ai +1 i + 1 = -1} . So M1 = {a11 = 1, a22 = -1, rest all elements = 0}
Please correct me if I'm wrong.
 A: Your answer is partially correct. For instance 
$$
A=\left( {\begin{array}{*{20}{c}}
   2 & 0 & 1  \\
   0 & { - 1} & 0  \\
   0 & 0 & { - 1}  \\
\end{array}} \right) \in M_3
$$
is not in the span of your basis because $a_{1,3} \ne 0$ but $trace(A)=0$. When $n=2$ your subspace is
$$\begin{align} M_2 &=\left\{  \left( {\begin{array}{*{20}{c}}
   a & b  \\
   c & d  \\
\end{array}} \right) | a,b,c,d \in \mathbb{R},a+d=0
  \right\} \\
&=\left\{  \left( {\begin{array}{*{20}{c}}
   a & b  \\
   c & {-a}  \\
\end{array}} \right) | a,b,c \in \mathbb{R}
  \right\} \\
&=\left\{ a \left( {\begin{array}{*{20}{c}}
   1 & 0  \\
   0 & {-1}  \\
\end{array}} \right) + b\left( {\begin{array}{*{20}{c}}
   0 & 1  \\
   0 & 0  \\
\end{array}} \right)+
c\left( {\begin{array}{*{20}{c}}
   0 & 0  \\
   1 & 0  \\
\end{array}} \right)| a,b,c \in \mathbb{R}
  \right\}  
\end{align}$$
so a a natural basis for $M_2$ is 
$$B=\left\langle   \left( {\begin{array}{*{20}{c}}
   1 & 0  \\
   0 & {-1}  \\
\end{array}} \right), \left( {\begin{array}{*{20}{c}}
   0 & 1  \\
   0 & 0  \\
\end{array}} \right),
\left( {\begin{array}{*{20}{c}}
   0 & 0  \\
   1 & 0  \\
\end{array}} \right)
   \right\rangle.$$
So $dim(M_2)=3=2*2-1$. To extend above idea, we have for $n \in \mathbb{N}$ 
$$\begin{align} M_n &=\left\{  \left( {\begin{array}{*{20}{c}}
   {{a_{1,1}}} &  \cdots  & {{a_{1,n}}}  \\
    \vdots  &  \ddots  &  \vdots   \\
   {{a_{n,1}}} &  \cdots  & {{a_{n,n}}}  \\
\end{array}} \right) | \sum\limits_{j=1}^{n}{a_{j,j}}=0
 \right\} \\
&=\left\{  \left( {\begin{array}{*{20}{c}}
   {{a_{1,1}}} &  \cdots  & {{a_{1,n}}}  \\
    \vdots  &  \ddots  &  \vdots   \\
   {{a_{n,1}}} &  \cdots  & {{a_{n,n}}}  \\
\end{array}} \right) | a_{n,n}=-\sum\limits_{j=1}^{n-1}{a_{j,j}}
 \right\} \\
&=\left\{  \left( {\begin{array}{*{20}{c}}
   {{a_{1,1}}} &  \cdots  & {{a_{1,n}}}  \\
    \vdots  &  \ddots  &  \vdots   \\
   {{a_{n,1}}} &  \cdots  & {{\sum\limits_{j=1}^{n-1}{-a_{j,j}}}}  \\
\end{array}} \right)
 \right\} \\
&=\left\{ {{a_{1,1}}\left( {\begin{array}{*{20}{c}}
   1 & 0 &  \cdots  & 0  \\
   0 &  \vdots  &  \vdots  &  \vdots   \\
    \vdots  &  \vdots  &  \vdots  & 0  \\
   0 &  \ldots  & 0 & { - 1}  \\
\end{array}} \right) + {a_{1,2}}\left( {\begin{array}{*{20}{c}}
   0 & 1 & 0 & 0  \\
   0 & 0 &  \vdots  &  \vdots   \\
    \vdots  &  \vdots  &  \vdots  & 0  \\
   0 &  \ldots  & 0 & { - 1}  \\
\end{array}} \right) +  \cdots  + {a_{n,n - 1}}\left( {\begin{array}{*{20}{c}}
   0 & 0 &  \cdots  & 0  \\
   0 &  \vdots  &  \vdots  &  \vdots   \\
    \vdots  &  \vdots  & 0 & 0  \\
   0 &  \vdots  & 1 & { - 1}  \\
\end{array}} \right)} \right\}
\end{align}
$$
and a natural basis for $M_n$ is
$$B={\left\langle {\left( {\begin{array}{*{20}{c}}
   1 & 0 &  \cdots  & 0  \\
   0 &  \vdots  &  \vdots  &  \vdots   \\
    \vdots  &  \vdots  &  \vdots  & 0  \\
   0 &  \ldots  & 0 & { - 1}  \\
\end{array}} \right),\left( {\begin{array}{*{20}{c}}
   0 & 1 & 0 & 0  \\
   0 & 0 &  \vdots  &  \vdots   \\
    \vdots  &  \vdots  &  \vdots  & 0  \\
   0 &  \ldots  & 0 & { - 1}  \\
\end{array}} \right), \cdots ,\left( {\begin{array}{*{20}{c}}
   0 & 0 &  \cdots  & 0  \\
   0 &  \vdots  &  \vdots  &  \vdots   \\
    \vdots  &  \vdots  & 0 & 0  \\
   0 &  \vdots  & 1 & { - 1}  \\
\end{array}} \right)} \right\rangle }
$$
hence $dim(M_n)=n^2 -1$.
A: The space $V$ of all $(n\times n)$-matrices has dimension $n^2$. A basis of $V$ is given by the set of matrices $E_{ik}$ $\>(1\leq i\leq n, \ 1\leq k\leq n)$ having a one at position $(i,k)$ and the rest zeros.
The subspace $W\subset V$ of matrices with trace zero can be written as direct sum of the space $U$ of matrices with zero diagonal and the space $D$ of diagonal matrices with trace zero: $W=U\oplus D$. The dimension of $U$ is $n^2-n$, and a basis of $U$ is given by the set of $E_{ik}$ with $i\ne k$. The matrices ${\rm diag}(d_1,d_2,\ldots, d_n)\in D$ satisfy the condition $\sum_{i=1}^n d_i=0$; so they form an $(n-1)$-dimensional space, and the matrices $$F_i:=E_{ii}-E_{nn}\qquad(1\leq i\leq n-1)$$ constitute a basis of $D$. 
All in all the space $W$ has dimension $n^2-1$.
