Examine the following graph. We will be running Dijkstra's algorithm starting at the node labeled S S 5 1 2 A E F 9 3 4 6 B D 5 We're using the version of Dijkstra's algorithm described here in lecture: note that the fringe and dist To data structures are always changed at the same time. Give the resulting edgeTo and distTo maps after vertex B is visited (i.e. its outgoing edges to C and E have been relaxed). Also give the resulting edgeTo and distro maps after Dijkstra's algorithm has completely finished execution. Initialize the edgeTo for each vertex as - which will represent null for us. Initialize the distro for each vertex as inf which we'll use to represent ∞, except for S where it should be 0. So, before the first iteration, the values of these variables are: edgeTo = {A, B, C:-, D:-, E:-, F:-, G:-, S:-} distTo = {A: inf, B:inf, C:inf, D:inf, E:inf, F:inf, G:inf, S:0} The maps must be in this order. If you have the same mappings but in a different order (i.e. the mapping for S comes first), Gradescope will say your answer is incorrect.

icon
Related questions
Question

Give edgeTo after B is visited. Format your answer as {A:?, B:?, C:?, D:?, E:?, F:?, G:?, S:-}.((Hint: the first step of the algorithm is to visit S, which should change the entries for A and B in edgeTo and distTo. The second step is to visit B, which should change the entries for C and E))

Give distTo after B is visited. Format your answer as {A:?, B:?, C:?, D:?, E:?, F:?, G:?, S:0}.

Give edgeTo after Djiksta's is finished. Format your answer as {A:?, B:?, C:?, D:?, E:?, F:?, G:?, S:-}.

Give distTo after Dijkstra's is finished. Format your answer as {A:?, B:?, C:?, D:?, E:?, F:?, G:?, S:0}.

Examine the following graph. We will be running Dijkstra's algorithm starting at the node labeled S
S
5
1
2
A
E
F
9
3
4
6
B
D
5
We're using the version of Dijkstra's algorithm described here in lecture: note that the fringe and
dist To data structures are always changed at the same time.
Give the resulting edgeTo and distTo maps after vertex B is visited (i.e. its outgoing edges to C and
E have been relaxed). Also give the resulting edgeTo and distro maps after Dijkstra's algorithm has
completely finished execution. Initialize the edgeTo for each vertex as - which will represent null
for us. Initialize the distro for each vertex as inf which we'll use to represent ∞, except for S
where it should be 0.
So, before the first iteration, the values of these variables are:
edgeTo = {A, B, C:-, D:-, E:-, F:-, G:-, S:-}
distTo = {A: inf, B:inf, C:inf, D:inf, E:inf, F:inf, G:inf, S:0}
The maps must be in this order. If you have the same mappings but in a different order (i.e. the
mapping for S comes first), Gradescope will say your answer is incorrect.
Transcribed Image Text:Examine the following graph. We will be running Dijkstra's algorithm starting at the node labeled S S 5 1 2 A E F 9 3 4 6 B D 5 We're using the version of Dijkstra's algorithm described here in lecture: note that the fringe and dist To data structures are always changed at the same time. Give the resulting edgeTo and distTo maps after vertex B is visited (i.e. its outgoing edges to C and E have been relaxed). Also give the resulting edgeTo and distro maps after Dijkstra's algorithm has completely finished execution. Initialize the edgeTo for each vertex as - which will represent null for us. Initialize the distro for each vertex as inf which we'll use to represent ∞, except for S where it should be 0. So, before the first iteration, the values of these variables are: edgeTo = {A, B, C:-, D:-, E:-, F:-, G:-, S:-} distTo = {A: inf, B:inf, C:inf, D:inf, E:inf, F:inf, G:inf, S:0} The maps must be in this order. If you have the same mappings but in a different order (i.e. the mapping for S comes first), Gradescope will say your answer is incorrect.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer