First of all note that Sparse means that you have very few edges, and Dense means many edges, or almost complete graph. In a complete graph you have $n(n−1)/2$ edges, where $n$is the number of nodes.
Now, when we use matrix representation we allocate $n×n$ matrix to store node-connectivity information, e.g., $M[i][j]=1$ if there is edge between nodes ii and jj, otherwise$ M[i][j]=0$.
But if we use adjacency list then we have an array of nodes and each node points to its adjacency list containing ONLY its neighboring nodes.
Now if a graph is sparse and we use matrix representation then most of the matrix cells remain unused which leads to the waste of memory. Thus we usually don't use matrix representation for sparse graphs. We prefer adjacency list.
But if the graph is dense then the number of edges is close to (the complete) $n(n−1)/2$, or to $(n^{2})$ if the graph is directed with self-loops. Then there is no advantage of using adjacency list over matrix.
n terms of space complexity
Adjacency matrix: $O(n^{2})$
Adjacency list: $O(n+m)$
where nn is the number nodes, mm is the number of edges.
When the graph is undirected tree then
Adjacency matrix: $O(n^{2})$
Adjacency list: $O(n+n)$ is $O(n)$ (better than $O(n^{2})$)
When the graph is directed, complete, with self-loops then
Adjacency matrix: $O(n^{2})$
Adjacency list: $O(n+(n^{2}))$ is $O(n^{2})$ (no difference)
And finally, when you implement using matrix, checking if there is an edge between two nodes takes $O(1)$ times, while with an adjacency list, it may take linear time in $O( n)$.
answer is none of these