Which graph representation uses space O(V+E)?

Prepare for the GATE General Aptitude and CS Test. Enhance your skills with multiple choice questions and detailed explanations. Elevate your readiness and boost your confidence for the exam!

Multiple Choice

Which graph representation uses space O(V+E)?

Explanation:
Adjacency lists balance memory by recording just what each vertex connects to. For every vertex you keep a small list of its neighbors, so the total number of neighbor entries across all vertices corresponds to the number of edges. Add the one pointer or head per vertex, and you get space that grows as V plus E, i.e., O(V+E). This makes adjacency lists particularly space-efficient for sparse graphs where E is much smaller than V^2. In contrast, an adjacency matrix stores a value for every possible pair of vertices, giving O(V^2) space. An incidence matrix uses a row for each vertex and a column for each edge, resulting in O(VE) space, which can be much larger than O(V+E) for typical graphs. An edge list saves only the edge endpoints, so its space is O(E) (often plus a small O(V) for vertex data), not O(V+E) in the general sense.

Adjacency lists balance memory by recording just what each vertex connects to. For every vertex you keep a small list of its neighbors, so the total number of neighbor entries across all vertices corresponds to the number of edges. Add the one pointer or head per vertex, and you get space that grows as V plus E, i.e., O(V+E). This makes adjacency lists particularly space-efficient for sparse graphs where E is much smaller than V^2.

In contrast, an adjacency matrix stores a value for every possible pair of vertices, giving O(V^2) space. An incidence matrix uses a row for each vertex and a column for each edge, resulting in O(VE) space, which can be much larger than O(V+E) for typical graphs. An edge list saves only the edge endpoints, so its space is O(E) (often plus a small O(V) for vertex data), not O(V+E) in the general sense.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy