Preorder traversal:
Visit the root first, then all subtrees (from left to right) in preorder.
Postorder traversal:
Visit first all subtrees (from left to right) in postorder, then visit roots.
Inorder traversal (binary trees only):
Visit the left subtree, then the root, then the right subtree.
Polish notation corresponds a preorder traversal of the binary tree representing an algebraic expression. Standard notation (with brackets) corresponds to inorder traversal.
Depth-first Search
INPUT: A connected graph ,
.
OUTPUT: A (depth-first) spanning tree of
.
Breadth-first Search
INPUT: A connected graph ,
.
OUTPUT: A (breadth-first) spanning tree of
.
Vertex set:
.
Adjacency matrix: