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 A on the map A-B, A-E, B-F, E-F, B-C, C-G and F-G. How many looks does it make?

A1BCEFGA
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, E, F and G, not the looks.
  • That adds the 6 places coming off, but coming off is no look.

new numbers

question 2

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

A1BCDEFGHA
the answer, and why

the answer is B

It reaches A, B, C and D, four places. D's only road leads back to C, so D comes off, and the walk steps back to C.

if you chose another

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

new 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 A

A-B, B-C, C-D, A-E, B-F is in one piece with 5 roads, 10 looks. A-B, B-C, C-G has 3 roads, 6 looks, and A-B, A-E, A-F, E-F 4 roads, 8.

if you chose another

  • 3 roads, 6 looks.
  • 4 roads, 8 looks.
  • It has 6 roads, but E's piece holds only E-F, so the walk makes 2 looks.

new numbers