logo

AQA A-Level Computer Science practice

Trace Dijkstra’s shortest path algorithm from A to D using the weighted graph with edges A-B = 4, A-C = 1, C-B = 2, B-D = 1 and C-D = 7. Show the important tentative distances as vertices are selected, and state the shortest route and its total distance.

Try the question first, then check the answer and practise the same topic again.

At a glance

Question

Type

practice

Style

Topic

Optimisation algorithms

Exam-style question

Try this first

Trace Dijkstra’s shortest path algorithm from A to D using the weighted graph with edges A-B = 4, A-C = 1, C-B = 2, B-D = 1 and C-D = 7. Show the important tentative distances as vertices are selected, and state the shortest route and its total distance.

Answer and explanation

Concise answer

Initially, A has distance 0 and B, C and D have no known distance.

Why this is correct

At each stage, the smallest available tentative distance is selected. Routes through the selected vertex are then checked to see whether they give shorter distances to connected vertices. The route through C and B improves the route to D.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions