Skip to content

Depth-first search

networks

Level 2 of 3

Also called DFS.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from depth-first search's own run on the numbers shown.

choose one

question 1

The walk starts at F on the map A-B, D-G, A-F, B-F, C-F, B-C and C-G. How many looks does it make?

ABCDF1GF
the answer, and why

the answer is D

The map is in one piece with 7 roads, and each is looked along from both ends, 14 in all.

if you chose another

  • That counts each road once, but each road gets a look from both ends.
  • That counts the places, A, B, C, D, F, G, not the looks.
  • That adds the 6 places coming off, but coming off is no look.

new numbersthe test page's numbers

question 2

On the town of eight from H, how many places has the walk reached when it first steps back?

ABCDEFGH1H
the answer, and why

the answer is A

It reaches H, G, B, A, 4 places. Every road from A leads to a place already reached, so A comes off, and the walk steps back to B.

if you chose another

  • 3 is the stack after the step back, H, G, B. A was reached too.
  • That is the whole town, but C, D, E, F are not reached yet.
  • C, the next place, is reached after the step back.

new numbersthe test page's numbers

question 3

The walk starts at the place after the semicolon on each map. On which map does it make the most looks?

the answer, and why

the answer is C

A-B, C-D, D-H, C-H, C-F, B-C; C makes 12 looks, two for each road in its start's piece, the most of the four.

if you chose another

  • That map makes 10 looks, fewer than 12.
  • That map makes 8 looks, fewer than 12.
  • That map makes 8 looks, fewer than 12.

new numbersthe test page's numbers