22-Elec-B4 Information Technology Networks · December 2019
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Paper format. National Examinations, December 2019 — 16-Elec-B4, Information Technology Networks. Three hours, closed book; an approved Casio or Sharp calculator is permitted. The paper prints five questions of 25 marks each, and any four constitute a complete paper worth 100 marks, with the marks for every sub-part shown in the left margin. All five questions are solved here, because this set is a study resource rather than an exam attempt, and a candidate choosing which four to write benefits from seeing the fifth worked out.
Reference texts. A. Leon-Garcia and I. Widjaja, Communication Networks: Fundamental Concepts and Key Architectures, 2nd ed. (the syllabus reference for this code); J. F. Kurose and K. W. Ross, Computer Networking: A Top-Down Approach, 8th ed.; A. S. Tanenbaum and D. J. Wetherall, Computer Networks, 5th ed.; W. Stallings, Wireless Communications and Networks, 2nd ed.; S. Sesia, I. Toufik and M. Baker, LTE — The UMTS Long Term Evolution, 2nd ed.; T. H. Cormen, C. E. Leiserson, R. L. Rivest and C. Stein, Introduction to Algorithms, 4th ed.
Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.
Given. The undirected weighted graph below, read directly from the examination page. Ten edges carry ten distance labels:
| Edge | A–B | A–C | A–D | B–E | C–D | C–F | D–F | E–F | E–G | F–G |
|---|---|---|---|---|---|---|---|---|---|---|
| Distance | 1 | 2 | 2 | 5 | 1 | 2 | 1 | 1 | 1 | 3 |
Find. The shortest distance and the corresponding path from source node F to each of A, B, C, D, E and G, with the algorithm's working shown at every iteration.
[Figure not reproduced. See the official exam paper.]
Approach. Maintain a set $N'$ of nodes whose shortest distance is already final, a tentative label $D(v)$ for every other node, and a predecessor $p(v)$ recording the node through which the current best path reaches $v$. Repeatedly move the unlabelled node of smallest tentative distance into $N'$ and relax its edges. Ties are broken alphabetically, which affects only the order of the table, never the final distances.
The full tableau. Each cell shows the tentative distance and, in parentheses, the predecessor; a bold entry is the label being made permanent in that step.
| Step | $N'$ (permanent set) | $D(A)$ | $D(B)$ | $D(C)$ | $D(D)$ | $D(E)$ | $D(G)$ |
|---|---|---|---|---|---|---|---|
| 0 | F | ∞ | ∞ | 2 (F) | 1 (F) | 1 (F) | 3 (F) |
| 1 | F, D | 3 (D) | ∞ | 2 (F) | — | 1 (F) | 3 (F) |
| 2 | F, D, E | 3 (D) | 6 (E) | 2 (F) | — | — | 2 (E) |
| 3 | F, D, E, C | 3 (D) | 6 (E) | — | — | — | 2 (E) |
| 4 | F, D, E, C, G | 3 (D) | 6 (E) | — | — | — | — |
| 5 | F, D, E, C, G, A | — | 4 (A) | — | — | — | — |
| 6 | F, D, E, C, G, A, B | — | — | — | — | — | — |
Reading the paths off the predecessors. Following $p(\cdot)$ back to F from each node gives
$$\boxed{\begin{aligned} F \to A &: F\!-\!D\!-\!A, \ \ 1+2 = 3 \\ F \to B &: F\!-\!D\!-\!A\!-\!B, \ \ 1+2+1 = 4 \\ F \to C &: F\!-\!C, \ \ 2 \\ F \to D &: F\!-\!D, \ \ 1 \\ F \to E &: F\!-\!E, \ \ 1 \\ F \to G &: F\!-\!E\!-\!G, \ \ 1+1 = 2 \end{aligned}}$$Two features of this particular network are worth pointing out to a marker. First, node C has two shortest paths of equal length: the direct edge F–C costs 2, and F–D–C costs $1 + 1 = 2$ as well. Dijkstra's algorithm keeps whichever it relaxed first — here the direct edge, discovered at initialisation — and the tie is genuine, so a candidate who reports F–D–C is equally correct. Second, the direct edge F–G is not on the shortest path to G: routing through E costs $1 + 1 = 2$ against the direct 3. This is the standard warning against confusing a one-hop route with a short one, and it is the reason link-state protocols such as OSPF and IS-IS run this algorithm rather than counting hops as RIP does. The six tree edges total $1 + 1 + 2 + 1 + 2 + 1 = 8$ units.
| Destination | Shortest distance from F | Path | First hop (forwarding entry at F) |
|---|---|---|---|
| A | 3 | F–D–A | D |
| B | 4 | F–D–A–B | D |
| C | 2 | F–C (F–D–C ties) | C (or D) |
| D | 1 | F–D | D |
| E | 1 | F–E | E |
| G | 2 | F–E–G | E |
| Total weight of the shortest-path tree | 8 units over six edges | ||