Complete the code to initialize the distance to the source node as zero.
distances[source] = [1];The distance from the source node to itself is always zero.
Complete the code to select the next node with the smallest tentative distance.
int u = [1];We pick the unvisited node with the smallest distance to explore next.
Fix the error in updating the distance if a shorter path is found.
if (distances[u] + graph[u][v] < distances[v]) { distances[v] = distances[u] [1] graph[u][v]; previous[v] = u; }
We add the edge weight to the current distance to update the neighbor's distance.
Fill both blanks to correctly remove the visited node and check if all nodes are visited.
unvisited.[1](u); while (unvisited.[2] > 0)
Remove the visited node from unvisited set and continue while unvisited nodes remain.
Fill all three blanks to correctly build the shortest path from source to target.
List<int> path = new List<int>(); int current = target; while (current != [1]) { path.[2](current); current = previous[[3]]; } path.[2](current); path.Reverse();
We trace back from target to source using previous nodes, adding each to the path list, then reverse it.
