The directed graph below has six vertices. Its adjacency lists, each already in alphabetical order, are:
Run a full depth-first search: the outer loop tries vertices in alphabetical order and starts a new search from any vertex that is still unvisited, and each call explores neighbours in list order. A single clock starts at 1 and advances by one at every discovery and every finish. Fill in the discovery and finish time of each vertex.
Unlock full course notes by signing up
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;
Marking vertices when queued or when removed
A network crawler keeps a frontier, the queue of records awaiting processing. It runs on a connected, undirected graph with VVV vertices and EEE edges, with no self-loops or parallel edges. Each edge counts as one hop, and the graph is stored using adjacency lists.
Compare two breadth-first search variants. Both use a first-in, first-out queue. Early marks each vertex seen when it is enqueued, records its distance then, and enqueues only unseen neighbours. Late instead runs the following code:
Assume the adjacency lists already exist and each set or queue operation shown takes constant time. Which statements are true? Select every true statement.