Traversal and search methods[You do not have permission to view the full content of this post.
Log in or register now.]
Main article:
You do not have permission to view the full content of this post.
Log in or register now.
Stepping through the items of a tree, by means of the connections between parents and children, is called
walking the tree, and the action is a
walk of the tree. Often, an operation might be performed when a pointer arrives at a particular node. A walk in which each parent node is traversed before its children is called a
pre-order walk; a walk in which the children are traversed before their respective parents are traversed is called a
post-order walk; a walk in which a node's left subtree, then the node itself, and finally its right subtree are traversed is called an
in-order traversal. (This last scenario, referring to exactly two subtrees, a left subtree and a right subtree, assumes specifically a
You do not have permission to view the full content of this post.
Log in or register now..) A
level-order walk effectively performs a
You do not have permission to view the full content of this post.
Log in or register now. over the entirety of a tree; nodes are traversed level by level, where the root node is visited first, followed by its direct child nodes and their siblings, followed by its grandchild nodes and their siblings, etc., until all nodes in the tree have been traversed.