edited by
19,647 views

6 Answers

Best answer
39 39 votes
For GATE purpose, without actually applying DFS, we can answer by just seeing options.
In DFS, we go in depth first i.e., one node to another in depth first order.

Here, $abfehg$  is not possible as we can not go from $f$ to $e$ directly.
Thus, option $(D)$ is correct.

In all the other options we can reach directly from the node to the next node.

So, just visualize and do.
edited by
7 7 votes

Answer will be (D)

DFS goes upto how much depth possible and then backtrack and go to the next link.

Here only 'abfehg' not possible because e and h consecutively is not possible by any backtracking of DFS traversal

5 5 votes
In dfs think of a stack as if every adjacent node is being put on top of it lifo and chosen randomly while in bfs think of a queue i.e.fifo here option d.
0 0 votes

We will go systematically and explore each vertices and it’s neighbors and will backtrack where possible. Let’s start-

  1. abeghf

    1. abfehg
      This is not possible as after exploring $f$ we will have unvisited vertices $h$,$g$ as neighbours, but $e$ can’t come.
    2. abfhge
       ​​​​​
    3. afghbe

$Ans: D$

0 0 votes
According to definition of DFS the path is explored until dead end but in option B it explores upto f only it possible explore dead end but it backtracks to again 'a' it violates definition of DFS.
Answer:
Position:
Show:

Related questions

61 61 votes
5 answers 5 answers
14.4k
14.4k views
Kathleen asked Sep 17, 2014
14,400 views
A program consists of two modules executed sequentially. Let $f_1(t)$ and $f_2(t)$ respectively denote the probability density functions of time taken to execute the two ...
75 75 votes
5 answers 5 answers
28.1k
28.1k views
Kathleen asked Sep 17, 2014
28,064 views
Let $G= (V,E)$ be a directed graph with $n$ vertices. A path from $v_i$ to $v_j$ in $G$ is a sequence of vertices ($v_{i},v_{i+1}, \dots , v_j$) such that $(v_k, v_{k+1})...
107 107 votes
5 answers 5 answers
31.0k
31.0k views
Kathleen asked Sep 17, 2014
30,994 views
Let $G =(V,E)$ be an undirected graph with a subgraph $G_1 = (V_1, E_1)$. Weights are assigned to edges of $G$ as follows.$$w(e) = \begin{cases} 0 \text{, if } e \in E_...
76 76 votes
7 answers 7 answers
44.1k
44.1k views
gatecse asked Feb 14, 2018
44,068 views
Let $G$ be a simple undirected graph. Let $T_D$ be a depth first search tree of $G$. Let $T_B$ be a breadth first search tree of $G$. Consider the following statements.No...