GATE / CS ARCHIVE

GATE CSE 2015 SET 1 / QUESTION 51

GATE CSE 2015 Set 1 Q51

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

GATE 2015 Set 1, Q51 2 marks · MCQ
Report issue

Graph Algorithms

Question 51, GATE 2015: G is a simple undirected graph, s a source, d(x) shortest distance from s, and T a BFS tree. For an edge (u,v) not in T, which cannot equal d(u)−d(v)? A −1; B 0; C 1; D 2.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

An edge gives a one-step extension of a shortest path: d(u)≤d(v)+1 and d(v)≤d(u)+1. Combining gives −1≤d(u)−d(v)≤1. BFS non-tree edges can connect two vertices on the same level or consecutive levels; being non-tree does not force equal levels. Distances must be finite, so interpret u,v as vertices in the explored source component.

Solution: For any edge joining reachable vertices u, v, a shortest path to v followed by that edge proves d(u)≤d(v)+1, and symmetrically d(v)≤d(u)+1. Hence their distances differ by at most 1, so 2 is impossible, D. The restriction to a non-tree edge does not change the bound; same-level and adjacent-level non-tree edges can occur. Distances are understood within the source component, since subtraction of two infinite unreachable distances is not defined.

Original paper, page 19 · Answer key