Is Depth-First-Search (DFS) same as Preorder in Binary Tree?
1
/ \
2 3
/ \ / \
4 5 6 7
\ \ / /
8
How about this case? ( start from vertex 1)
With preorder, my answer is 12485367
With DFS, my answer is 12485637
what's the problem?
Yes! DFS and Preorder are equivalent.
- vodangkhoa February 01, 2007BFS is a totally different beast compare to preorder, inorder, and postorder.
Here is the link to tree traversal algorithms.
http://en.wikipedia.org/wiki/Tree_traversal