GATE / CS ARCHIVE

GATE CSE 2016 SET 1 / QUESTION 38

GATE CSE 2016 Set 1 Q38

Algorithms · Graph Algorithms · Full GATE CSE 2016 Set 1 paper

GATE 2016 Set 1, Q38 2 marks · NAT
Report issue

Graph Algorithms

Question 38, GATE 2016: A four-vertex weighted undirected graph has weight matrix W with rows (0,2,8,5), (2,0,5,8), (8,5,0,x), (5,8,x,0). Find the largest integer x for which some shortest path between some pair uses the edge of weight x.
Tap to enlarge
Answer & solution

Official answer: 12.0 : 12.0

Our answer: 12

Without edge 3–4, the shortest route between its endpoints is 3→2→1→4 of length 5+2+5=12; the two-edge alternatives both cost 13. Any edge heavier than an alternative endpoint path cannot occur in a shortest path, since replacing it improves the route. At x=12 the edge itself ties the shortest endpoint route, so the largest integer is 12.

It suffices to compare x against the best route between its own endpoints that avoids that edge. Any shortest path using a heavier edge could be improved by substituting that alternative segment. The relevant routes from 3 to 4 have costs 13 via 1,13 via 2,12 via 2 then 1, and 18 via 1 then 2; thus 12 is the threshold. Equality is allowed because the question requires at least one shortest path, not a uniquely shortest path. At x=12, the direct edge is itself a shortest 3-to-4 path.

Original paper, page 15 · Answer key