close

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.

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 lettice0913 的頭像
    lettice0913

    斑的家

    lettice0913 發表在 痞客邦 留言(0) 人氣()