What are the advantage and disadvantages of Level Order Traversal compare to Depth Order Traversal(in-order, pre-order, post-order) ?
Asked
Active
Viewed 535 times
0
-
What is your application, tree traversal methods are used generally for specific applications. You might want to start with the wikipedia page. – UglyCode Nov 11 '15 at 19:15
2 Answers
0
I think your problem is the same as Breadth-First-Search VS Depth-First-Search. I couldn't say which is better. It is depend on your application.

liuniandxx
- 1
- 1
-
-
Level Order Traversal and Depth Order Traversal have same time complexity and space complexity. – liuniandxx Dec 01 '15 at 14:19
0
Here : Breadth First Vs Depth First, you can find a good explanation of the two methods (given that by level order you mean a particular kind of breadth search). The pro/cons of the two are various:
- if you expect to find data quite up in the graph, than BFS would be better in time since passes to the next depth level only after having explored the whole super-level. If you instead expect to find a node quite at the bottom of the graph, DFS is better for the opposite reason.
- if the graph/tree is huge, and particularly large (nodes with lots of children/adjacencies for each level), the queue that BFS implements will require a lot of memory, while the stack memory of the vertical recursive call should be reasonably smaller, so DFS could be preferable: here too, the opposite for really narrow graphs.
- for paths in the graph, BFS will always return first the shortest path it encounters, while DFS could return first a path that's not necessarily the shortest.
- both have same worst case time complexity (if the required node is the last one you encounter).

Community
- 1
- 1

Matteo Di Napoli
- 567
- 5
- 17