Medium

Graph Representation

A graph is vertices plus edges. An adjacency list spends memory on the edges that exist. An adjacency matrix spends a cell on every possible pair.

Costs

CategoryData Structure
DifficultyMedium
Adjacency list memoryO(V + E)
Adjacency matrix memoryO(V²)
Choose a list whenthe graph is sparse

Questions

What is Graph Representation?

A graph is vertices plus edges. An adjacency list spends memory on the edges that exist. An adjacency matrix spends a cell on every possible pair.

Where do I practice it?

DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.