Question Details

Consider the directed graph G = (V, E) where V is the finite set of vertices and E is the set of directed edges between the vertices. G may contain cycle but there is no self-loop, further G may not be strongly connected. Let GR be the graph obtained by reversing direction of all edges without changing set of vertices. Assume that BFS or DFS for any given vertex V of a graph will visit only the reachable vertices from V in that graph. Which of the following statement must always be true regardless of the structure of G?

Options

A

In GR, BFS traversal from V will visit exactly the same set of vertices as the DFS from V in G.

B

If U is a reachable vertex in the DFS of G from V then V is also a reachable vertex in the BFS of GR from U.

C

If U is a reachable vertex in the BFS of GR from V then U is also a reachable vertex in the DFS of G from V.

D

The order of vertices visited in the BFS of GR from V is the reverse of the order of vertices visited in the DFS of G from V.

Show Answer

Correct Answer :

Option B

If U is a reachable vertex in the DFS of G from V then V is also a reachable vertex in the BFS of GR from U.

Solution :

The correct option is: If U is a reachable vertex in the DFS of G from V then V is also a reachable vertex in the BFS of GR from U.

Here is the step-by-step explanation of why this statement is always true:

1. Understanding Reachability in Graph G:
If a vertex U is reachable from V in the directed graph G, it means there exists a directed path starting at V and ending at U. Let this path be represented as:
Vv1v2vkU
where each transition represents a directed edge in the set of edges E of G.

2. Reversing the Edges (Graph GR):
The graph GR is constructed by reversing the direction of all edges in G. This means that for every directed edge xy in G, there exists a corresponding directed edge yx in GR.

3. Path in the Reversed Graph:
Applying this reversal to our original path from V to U, the reversed path exists in GR as:
Uvkv2v1V
Since this sequence of directed edges exists in GR, it implies that V is reachable from U in the graph GR.

4. Traversal Reachability:
By definition, a Breadth-First Search (BFS) or Depth-First Search (DFS) starting from a vertex will visit all vertices that are reachable from it. Since V is reachable from U in GR, any BFS traversal starting from U in GR must eventually visit V. Thus, V is a reachable vertex in the BFS of GR from U.

Unlock Our Free Library

Access expert-curated educational resources and study materials—completely free.

Discover more resources

You may also like

Mock Tests

View All
  • GATE
  • beginner
  • 3 hours
  • computer science and information technology

  • GATE
  • intermediate
  • 3 hours
  • computer science and information technology

Ask AI Tutor
5 left
Q1 View Question & Options
AI Tutor is solving this question...
Reading question context & options...