Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE 2017 MOCK II | Question 20

  • Last Updated : 14 Feb, 2018

Consider the following statements:

S1 : DFS of a directed graph always produces the same number of edges in the traversal, irrespective of the starting vertex.
S2 : If all of the back edges that are found while DFS traversal on directed graph are removed, the resulting graph is acyclic.

Which of the following statements above are valid ?

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

(A) Both S1 and S2 are valid
(B) Only S1 is valid
(C) Only S2 is valid
(D) Neither s1 nor S2 is valid

Answer: (C)

Explanation: Statement S1 : consider the graph


Starting with A (source vertex ) we will get 2 edges
Starting with B will get only 1 edge
Starting with C we will get no edge

Therefore DFS on directed graph may not give same number of edges.

Statement S2 : Back edges are those edges (u,v) connecting a vertex u to an ancestor u in a
depth-first tree. Self-loops are considered to be back edges. Back edges describe descendant-to-ancestor relations, as they lead from “high” to “low” nodes.
Suppose that there is a back edge (u, v). Then vertex v is an ancestor of vertex u in the depth-first forest. There is thus a path from v to u in G, and the back edge (u,v) completes a cycle. Removing the back edge will break the cycle.

Therefore removing all the back edges will make the graph acyclic. So the statement is true.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!