Counting the work of breadth-first search

A connected, undirected road network has 1,200 intersections (vertices) and 4,500 road segments (edges), with no self-loops or repeated edges. You run one breadth-first search from a single start intersection, marking each vertex as visited when it is added to the queue.


Give each answer as an exact whole number:

  • the total number of adjacency-list entries the search reads when the graph is stored as adjacency lists;
  • the total number of matrix cells the search reads when the graph is stored as a 1,200 × 1,200 adjacency matrix, scanning a full row for each dequeued vertex;
  • the total number of enqueue operations, counting the start vertex.
Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Graph Traversals Questions: