Question goes as:
We know that there may be many possible DFS trees for a graph depending upon the start vertex and the order in which we explore the neighbors of each vertex.
Given a connected graph G = (V, E), you are given a rooted tree T such that each edge of this tree is present in E. Design an efficient algorithm to determine if T is a DFS tree of G.
What is the meaning of "tree T is not a DFS Tree" (assuming it spans the entire graph)?
If I don't have any ordering of tree vertices in the adjacency list representation (which I presume the question inherently claims), I could traverse in any fashion and create the tree that is given in the question.
EDIT : I think I came to know about a "non - DFS tree T", it is simply the tree that spans but isn't possibly creatable in any possible DFS, since we have a restriction that ALL children must be visited first in a DFS tree before returning to parent. Still, can anyone help with the efficient Algo.
eg:
A -- B
/ \
C - D
this graph has a Tree T as:
A -- B
/ \
C D
but this isnt a valid DFS tree !
DFS starting at vertex A.
Thanks in advance!
What is the meaning of "tree T is not a DFS Tree"as in the question it is saidT is a DFS tree of G- Mathews Sunny