Practice mode Data Structures

What is the space required to store a graph with V vertices and E edges as an adjacency matrix?

Correct answer D. O(V²)

Explanation

An adjacency matrix has one cell for every ordered pair of vertices, giving V × V entries regardless of how many edges exist. It answers 'is there an edge from u to v?' in O(1). An adjacency list stores only the edges that exist, needing O(V + E) space, which is far smaller for sparse graphs. That is why lists are preferred for most real-world graphs.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.