Many people may know about pre-order,in-order,post-order.
When the program is written in (pre-order)
traversal(node *t)
{
do_something()
traversal(t->left)
traversal(t->right)
}
Actually, it is just to traverse all the nodes
but different order could be used for different applicatoin
pre-order : the current node does something, then go to left, and right subtree, which means
the left and right subtree can gain information from its parent
post-order: go to left , and right subtree, then do the current node, which means
the current node can gain information from its children
in-order: go to left , current node then right subtree, which means
the current node could play a role as a bridge to pass information from the left subtree
to the right subtree.
留言列表