Related Articles

Related Articles

GATE | GATE-CS-2015 (Set 1) | Question 55
  • Last Updated : 20 Feb, 2015

Let G = (V, E) be a simple undirected graph, and s be a particular vertex in it called the source. For x ∈ V, let d(x) denote the shortest distance in G from s to x. A breadth first search (BFS) is performed starting at s. Let T be the resultant BFS tree. If (u, v) is an edge of G that is not in T, then which one of the following CANNOT be the value of d(u) – d(v)?
(A) -1
(B) 0
(C) 1
(D) 2

Answer: (D)

Explanation: Note that the given graph is undirected, so an edge (u, v) also means (v, u) is also an edge.

Since a shorter path can always be obtained by using edge (u, v) or (v, u), the difference between d(u) and d(v) can not be more than 1.

Quiz of this Question


My Personal Notes arrow_drop_up
Recommended Articles
Page :