Depth-First Search is a tree traversal in a depth-frist order. ie The search tree is deepened as much as possible on each child before going to the next sibling.
At node N, in any order:
Traversal Type | Condition |
---|---|
left-to-right | If (L) is done before (R) |
right-to-left | If (R) is done before (L) |
The order prefix (ie pre in pre-order) refers to the display position of the root or current node.
Order | display the root or current node (…) the left or right branch of the tree |
---|---|
pre-order | before |
in-order | between (only for binary tree) |
post-order | after |
h
/ | \
/ | \
d e g
/|\ |
/ | \ f
a b c