Forty Gigabytes Of Zeroes

A road network has V=100,000V = 100{,}000 intersections and E=200,000E = 200{,}000 two-way roads. A teammate wants int adj[100000][100000] because an edge lookup is then a single array read, and the container has 4 GB of RAM.

Assume a 4-byte int and count 1 GB = 10^9 bytes. How much does each representation need?

A

Matrix about 10 GB, adjacency list about 3.2 MB

B

Matrix about 40 GB, adjacency list about 1.6 MB

C

Matrix about 40 MB, adjacency list about 1.6 MB

D

Matrix about 400 MB, adjacency list about 800 KB