Chapter 9 Trees and Binary Trees | 9.17
subtree(L)
postorder_traversal(RCHILD(NODE)); //postorder traverse of the right
sub tree(R)
Visit(DATA(NODE)); //visit the node
}
End of postorder_traversal.
e postorder traversal of the binary tree depicted in Figure 9.10 starts with the root
A
,
A
has the le sub-
tree,
LCHILD(A)=B
, move to
B
,
B
also has a le subtree
D,
move to
D
and
D
also has the le subtree
G
, move
to
G
.
G
does not have the le child,
LCHILD(G)=NIL
and it also does not have the right child,
RCHILD(G)=NIL
so visit
G
. Trace back by one node to
D;
the le subtree of
D
is visited and it does not have any right child, i.e.
RCHILD(D)=NIL
, so visit
D
, trace back by one node to
B
. e nodes in the le ...