Skip to content

Dijkstra's shortest paths

networks

Level 2 of 3

Also called Dijkstra's algorithm and Single-source shortest paths.

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 dijkstra's shortest paths's own run on the numbers shown.

choose one

question 1

The search runs from A to G on this map. What distance does it settle G at?

6216442A0BCEFG
the answer, and why

the answer is B

The shortest way is A, E, F, G, which is 2 + 1 + 4, so 7.

if you chose another

  • That is A, B, C, G, 6 + 4 + 2, longer than 7.
  • That adds only A-E and F-G, leaving out E-F.
  • That is A, E, F, B, C, G, a longer way round.

new numbersthe test page's numbers

question 2

On this map, from A to H, which place is settled fourth?

73213364A0BCEFGH
the answer, and why

the answer is C

A at 0, E at 3 and F at 5 come first. Through F, place B is 6, beating its 7.

if you chose another

  • Place C is 9 away, after place B.
  • Place F, at 5, is settled third.
  • Place G is 11 away, after place C.

new numbersthe test page's numbers

question 3

The search runs from the first place after the semicolon to the second. On which map does it weigh up the most places?

the answer, and why

the answer is A

D-G 8, C-F 7, A-E 8, A-F 8, C-D 5; A G weighs up 7 places, the most of the four.

if you chose another

  • That map weighs up 3 places, fewer than 7.
  • That map weighs up 5 places, fewer than 7.
  • That map weighs up 5 places, fewer than 7.

new numbersthe test page's numbers