GateAI
Shortest Paths

GATE CSE 2016 Set 1 · Q38

NAT2 marksMedium

Time

Consider the weighted undirected graph with 4 vertices, where the weight of edge {i,j}\{i, j\} is given by the entry WijW_{ij} in the matrix WW. W=[02852058850x58x0]W = \begin{bmatrix} 0 & 2 & 8 & 5 \\ 2 & 0 & 5 & 8 \\ 8 & 5 & 0 & x \\ 5 & 8 & x & 0 \end{bmatrix} The largest possible integer value of xx, for which at least one shortest path between some pair of vertices will contain the edge with weight xx is _______.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 12

Shortest Paths

Let the 4 vertices be 1,2,3,41, 2, 3, 4.

The edge with weight xx connects vertices 33 and 44, i.e., e={3,4}e = \{3, 4\}.

For the edge {3,4}\{3, 4\} to be part of at least one shortest path between some pair of vertices, it must be part of a shortest path between its endpoints 33 and 44 (since all edge weights are positive, if it is used in any shortest path, the direct path between 33 and 44 will use it at least when x≤dist(3,4)x \le \text{dist}(3, 4) via alternative paths).

Let us compute all possible alternative paths between vertex 33 and vertex 44 not using the direct edge {3,4}\{3, 4\}:

  1. Path 3−1−43 - 1 - 4: weight =W31+W14=8+5=13= W_{31} + W_{14} = 8 + 5 = 13

  2. Path 3−2−43 - 2 - 4: weight =W32+W24=5+8=13= W_{32} + W_{24} = 5 + 8 = 13

  3. Path 3−2−1−43 - 2 - 1 - 4: weight =W32+W21+W14=5+2+5=12= W_{32} + W_{21} + W_{14} = 5 + 2 + 5 = 12

  4. Path 3−1−2−43 - 1 - 2 - 4: weight =W31+W12+W24=8+2+8=18= W_{31} + W_{12} + W_{24} = 8 + 2 + 8 = 18

The shortest alternative path between vertex 33 and vertex 44 has weight 1212.

For edge {3,4}\{3, 4\} to be part of at least one shortest path between 33 and 44, its weight xx must satisfy:

x≤12x \le 12

When x=12x = 12, the direct edge {3,4}\{3, 4\} provides a shortest path of length 1212 (tied with 3−2−1−43-2-1-4). If x>12x > 12, the path 3−2−1−43-2-1-4 is strictly shorter, so the edge of weight xx would not belong to any shortest path.

Thus, the largest possible integer value of xx is 12.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Shortest Paths previous year question is Q38 of the GATE CSE 2016 Set 1 paper. Find more GATE CSE PYQs on Shortest Paths in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 4 related Shortest Paths PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Shortest Paths in GATE CSE

Shortest Paths has 4 GATE CSE PYQs across 4 papers from 2012 to 2026. This is the only 2-mark NAT question among them, and it is the only one in GATE CSE 2016 Set 1.

How GATE tests Shortest Paths

More from GATE CSE 2016 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2016 Set 1 · Q38 · NAT

Consider the weighted undirected graph with 4 vertices, where the weight of edge {i, j} is given by the entry Wij in the matrix W. W = 0 & 2 & 8 & 5 2 & 0 & 5 & 8 8 & 5 & 0 & x 5 & 8 & x & 0 The largest possible integer value of x, for which at least one shortest path between some pair of vertices will contain the edge with weight x is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.