We consider the following code on Matlab with N an integer.
diag = 3*speye(N,N); % diagonal
subd=-sparse(2:N,1:N-1,1,N,N);
A=diag+subd+2*subd';
C=full(A);
If I am not wrong, sparse format keeps only non-zero entries, so it needs less memory. I noticed that when N=2,...,6, the size of A is bigger than the size of C even if A is in sparse format. Can someone explain why ?