---
title: "Dijkstra shortest path (2068 Bhadra)"
subject: "Discrete Structure"
chapter: 4
key: "semester_4/discrete_structure:dijkstra-2068-bhadra"
source: https://www.bctengineer.com/q/semester_4/discrete_structure/dijkstra-2068-bhadra
site: BCT Engineering
---

# Dijkstra shortest path (2068 Bhadra)

Discrete Structure · Chapter 4: Graph Theory

- Asked in: 2068 Bhadra, 8 marks
- Video: [Dijkstras Shortest Path Algorithm Explained | With Example | Graph Theory](https://www.youtube.com/watch?v=bZkzH5x0SKU) — FelixTechTips
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/discrete_structure/dijkstra-2068-bhadra
- Whole chapter: https://www.bctengineer.com/md/semester_4/discrete_structure/chapter-4

## Question

Use Dijkstra's algorithm to find the length of the shortest path between the vertices a and z in the weighted graph displayed below. [Figure: weighted graph on vertices a, b, c, d, e, z with edges a-b 4, a-c 2, b-c 1, b-d 5, c-d 8, c-e 10, d-e 2, d-z 6, e-z 3]

## Short answer

Dijkstra's algorithm iteratively fixes the vertex with smallest tentative distance, updating neighbors. The shortest path length from a to z is 13, along a-c-b-d-e-z (2+1+5+2+3).

## Answer

Dijkstra's algorithm (non-negative weights) labels every vertex with the best distance known so far and fixes one vertex at a time:
1. Give the source distance 0 and every other vertex ∞. All vertices are temporary.
2. Make the temporary vertex with the smallest label permanent.
3. For each temporary neighbour v of the new permanent vertex u: if d(u) + w(u,v) < d(v), set d(v) = d(u) + w(u,v) and record u as predecessor.
4. Repeat steps 2 and 3 until the target (or all vertices) is permanent.

#### Graph as read
Source a, target z.

Edges: a–b 4, a–c 2, b–c 1, b–d 5, c–d 8, c–e 10, d–e 2, d–z 6, e–z 3.

#### Trace
Each cell shows label = distance(predecessor). **Bold** marks the vertex made permanent in that step; ✓ means already permanent.

| Step | Fixed | a | b | c | d | e | z |
|---|---|---|---|---|---|---|---|
| 1 | a | **0** | 4(a) | 2(a) | ∞ | ∞ | ∞ |
| 2 | c | ✓ | 3(c) | **2**(a) | 10(c) | 12(c) | ∞ |
| 3 | b | ✓ | **3**(c) | ✓ | 8(b) | 12(c) | ∞ |
| 4 | d | ✓ | ✓ | ✓ | **8**(b) | 10(d) | 14(d) |
| 5 | e | ✓ | ✓ | ✓ | ✓ | **10**(d) | 13(e) |
| 6 | z | ✓ | ✓ | ✓ | ✓ | ✓ | **13**(e) |

#### Result
Shortest distance from a to z = **13**.

Shortest path (highlight these edges): **a → c → b → d → e → z** with edge weights 2 + 1 + 5 + 2 + 3 = 13.

**Answer:** shortest path length = 13 along a → c → b → d → e → z (2 + 1 + 5 + 2 + 3).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. At each step Dijkstra's algorithm makes permanent:
   A. The vertex with the most neighbours
   B. The vertex with fewest edges to the target
   C. The temporary vertex with the smallest label
   D. A vertex chosen at random
   Answer: C. The smallest temporary label is final when all weights are non-negative. (Key point: Dijkstra step)

2. A neighbour v of the newly fixed vertex u gets a new label when:
   A. w(u,v) < d(u)
   B. d(v) is already permanent
   C. d(u) > d(v)
   D. d(u) + w(u,v) < d(v)
   Answer: D. The label is replaced only if the route through u is shorter. (Key point: Relaxation)

3. Shortest distance from a to z:
   A. 13, along a-c-b-d-e-z
   B. 14 via a-b-d-z
   C. 10
   D. 15
   Answer: A. 2 + 1 + 5 + 2 + 3 = 13; a-b-d-z costs 15. (Key point: Result)

4. After c is fixed (distance 2), the label of b becomes:
   A. 4 direct
   B. 3 via c
   C. 1
   D. 5
   Answer: B. 2 + 1 = 3 beats the direct edge 4. (Key point: Improvement)

## Close variants set in other exams

- [Dijkstra shortest path (2071 Bhadra)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2071-bhadra) — Discrete Structure, chapter 4, asked 4×
- [Dijkstra shortest path (2070 Magh)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2070-magh) — Discrete Structure, chapter 4, asked 4×
- [Dijkstra shortest path (2069 Bhadra)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2069-bhadra) — Discrete Structure, chapter 4, asked 4×

## Related in Discrete Structure

- [Dijkstra shortest path (2075 Bhadra)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2075-bhadra) — Discrete Structure, chapter 4
- [Dijkstra shortest path (2074 Bhadra)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2074-bhadra) — Discrete Structure, chapter 4
- [Dijkstra shortest path (2072 Asoj)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2072-asoj) — Discrete Structure, chapter 4
- [Dijkstra shortest path (2073 Magh)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2073-magh) — Discrete Structure, chapter 4

## Related in other subjects

- [Dijkstra's shortest path algorithm](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adijkstra-algorithm-example) — Data Structure and Algorithm, chapter 10, asked 2×
- [Dijkstra's shortest paths from source F](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adijkstra-graph-source-f) — Data Structure and Algorithm, chapter 10
