Content deleted Content added
Tag: Reverted |
Tag: Reverted |
||
Line 21:
| ''Post-order (node visited at position blue {{colorbull|#2A7FFF|round|size=180}})'':{{br}} A, C, E, D, B, H, I, G, F.
}}]]
In ''depth-first search'' (DFS), the search tree is deepened as much as possible before going to the next sibling. In this, an algorithm traverses a graph by first going to the farthest point it can along each branch, then going back to the root node. The method relies on the stack data structure to remember which vertex it should proceed to next.
The two most common forms of DFS are:
#: 1. Recursive DFS
#: 2. Iterative DFS
To traverse binary trees with depth-first search, perform the following operations at each node:<ref>[http://www.cise.ufl.edu/~sahni/cop3530/slides/lec216.pdf ''Binary Tree Traversal Methods'']</ref><ref>{{cite web|url=http://www.programmerinterview.com/index.php/data-structures/preorder-traversal-algorithm/|title=Preorder Traversal Algorithm|access-date=2 May 2015}}</ref>
|