Reputation: 281
Let's say I have this graph and I want to use DFS from A to G, if I convert it into a tree search, will that make any change ? I tried and that is what I found, and please correct to me if I am wrong
Graph search : Frontier (LIFO):
A
B C E
D F C E *
C E
G E
E
G is the goal state
and for the Tree search things will be the same but only the graph could me more simple
so what is the difference between graph and tree in this case ? please help
Upvotes: 0
Views: 1103
Reputation: 136
I'm an amateur in this area too but I'll try and answer your query. As far as I understand it, trees by definition, do not contain cycles or loops. ref: http://freefeast.info/difference-between/difference-between-trees-and-graphs-trees-vs-graphs/
The link also lists the exact differences between graphs and trees.
So, technically, using a tree for DFS in your example would be wrong as it contains a loop.
Upvotes: 1