Exercise 1: Adjacency Matrix vs. List for a Road Network — Possible Solution ==================================================================== GIVEN ------------------------------ V = 500 intersections, each connected to an average of 4 others. STEP 1: THE NUMBER OF EDGES ------------------------------ Since each of the 500 vertices has an average of 4 connections, and each edge is shared between two vertices (each edge gets counted once from each end), the total edge count is: E = (500 x 4) / 2 = 2000 / 2 = 1,000 STEP 2: ADJACENCY MATRIX SPACE ------------------------------ V^2 = 500 x 500 = 250,000 cells STEP 3: ADJACENCY LIST SPACE ------------------------------ V + 2E = 500 + (2 x 1,000) = 500 + 2,000 = 2,500 entries STEP 4: THE RATIO ------------------------------ 250,000 / 2,500 = 100 The adjacency matrix would need exactly 100 times more space than the adjacency list to represent this same road network - an even larger gap than this chapter's own 1,000-user social network example (90.9x), since this network is sparser relative to its size. WHY THIS WORKS AS AN ANSWER ------------------------------ The edge count is derived correctly from the average-connections figure (dividing by 2 to avoid double-counting each edge), and both space formulas are applied directly from this chapter's own definitions before computing the final ratio explicitly.