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

A0BEFGA
the answer, and why

the answer is C

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, E, F and G, not the roads looked along.
  • That misses one look. G has degree 1, so it looks along its road too.

new numbers

question 2

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

A0BCDEFGHA
the answer, and why

the answer is B

A leaves first and finds B, then E. B leaves second and finds C, then F. E leaves third, so C is fourth.

if you chose another

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

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

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

if you chose another

  • 3 roads, 6 looks.
  • 4 roads, 8 looks.
  • It has 5 roads, but A's piece holds only A-B, so the walk looks along 2.

new numbers