Skip to content

Breadth-first search

networks

Level 2 of 3

Also called BFS.

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 breadth-first search's own run on the numbers shown.

choose one

question 1

The walk starts at G on the map D-G, F-G, B-F, B-G and C-G. How many roads does it look along?

BCDFG0G
the answer, and why

the answer is A

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

if you chose another

  • That counts each road once, but the walk looks along it from both ends.
  • That counts the places found, B, C, D, F, not the roads looked along.
  • That misses one look. C has degree 1, so it looks along its road too.

new numbersthe test page's numbers

question 2

On the town of eight from D, which place leaves the queue fourth?

ABCD0EFGHD
the answer, and why

the answer is B

Places leave the queue in the order they join it: D, C, F, G. So G leaves fourth.

if you chose another

  • F joins third, after D and C, so it leaves third.
  • B joins after G, so it leaves after G.
  • H is 3 roads from D, found only when G leaves.

new numbersthe test page's numbers

question 3

The walk starts at A on each map. Which one makes it look along the most roads?

the answer, and why

the answer is D

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

if you chose another

  • That map makes 6 looks, fewer than 12.
  • That map makes 6 looks, fewer than 12.
  • That map makes 6 looks, fewer than 12.

new numbersthe test page's numbers