2082 8

BIT152 · 2082 · 5 marks

Find the shortest path from a to z in following graph using Dijkstra’s algorithm.

Find the shortest path from a to z in following graph using Dijkstra’s algorithm. [5]

Discrete StructureChapter 9: Trees and Graph AlgorithmsDijkstra's algorithm for shortest pathsNumerical: Dijkstra's shortest path

Given

Problem: Find shortest path from $a$ to $z$ using Dijkstra's algorithm.

Critical issue: The question refers to a graph ("following graph"), but no graph image, edge list, or weight data is provided in the text supplied to me.

Dijkstra's algorithm requires:

  • The set of vertices
  • The set of edges connecting them
  • The weight/cost of each edge

None of these are present in the question. The graph is entirely missing.


Solution

Because the actual graph is unavailable, I cannot compute the genuine shortest path for this specific exam problem. The correct answer depends entirely on the edges and weights shown in the missing figure, which cannot be recovered or guessed.

What I can provide: the method (procedure marks)

Dijkstra's algorithm for source $a$ to destination $z$:

  1. Initialize $dist[a] = 0$, $dist[v] = \infty$ for all other $v$; mark all unvisited; set $prev[v]$ = undefined.
  2. Select the unvisited vertex $u$ with the smallest $dist[u]$.
  3. Relax each unvisited neighbor $v$ of $u$: $$\text{if } dist[u] + w(u,v) < dist[v] \implies dist[v] = dist[u] + w(u,v),; prev[v] = u$$
  4. Mark $u$ as visited.
  5. Repeat steps 2 to 4 until $z$ is visited (or all vertices processed).
  6. Trace back from $z$ via $prev[\cdot]$ to obtain the shortest path.

Note on the Missing Graph

Because the figure is missing, the trace below uses a standard textbook graph with these edges and weights:

$$a\text{-}b=4,; a\text{-}c=7,; b\text{-}c=2,; b\text{-}d=3,; b\text{-}e=2,; c\text{-}d=3,; d\text{-}z=5,; e\text{-}z=1$$

This data does not come from the question. The resulting path:

$$\text{Path } a \to b \to e \to z = 7$$

is internally consistent for that assumed graph (the arithmetic is correct: $4 + 2 + 1 = 7$), but it corresponds to a graph that was not given, so it cannot be validated as the answer to the actual exam problem.

Conclusion

The graph data is missing. No definitive shortest path or distance can be computed. To solve this problem, the vertex set, edge set, and edge weights from the figure are required.

If the intended graph is the one used here, the answer $a \to b \to e \to z$ with cost $7$ follows, but that cannot be confirmed without the original figure.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.