recategorized by
1,191 views
0 votes
0 votes
preorder traversal of a tree resemble to the DFS traversal of graph?
recategorized by

1 Answer

Best answer
2 votes
2 votes

It is true if the graph is acyclic..

The logic being in DFS we continue in the path till the leaf level and then backtrack and then go ot other unvisited nodes after backtracking to common ancestor ..

In fact DFS can be simulated using any of the postorder , preorder and in order traversal..

For implementation detail of each type , plz check : 

https://en.wikipedia.org/wiki/Tree_traversal#Implementations

selected by

Related questions

1 votes
1 votes
1 answer
1
1 votes
1 votes
2 answers
2
aaru14 asked Dec 7, 2017
2,350 views
assume the preorder tŕaversal of binary tree is "abc" how many total different binary trees are possible whose postorder traversal.is "cba" with the given preorder trave...
0 votes
0 votes
0 answers
3
sushmita asked Feb 3, 2017
278 views
WHY CROSS EDGES TURN TO BE BACK EDGES IN UNDIRECTED GRAPH IN DFS TRAVERSAL?? CAN ANYONE EXPLAIN THIS. WHY ARE THERE NO CROSS EDGES IN DFS OF UNDIRECTED GRAPH??
2 votes
2 votes
1 answer
4
go_editor asked Jul 30, 2016
2,059 views
Level order Traversal of a rooted Tree can be done by starting from root and performing:Breadth First SearchDepth First SearchRoot SearchDeep Search