1. in order tranversal :
procedurebegin
if current<>nil then
begin
inorder(current|left);
{assert: names in all nodes in left subtree of current node have
been printed in lexical order}
writln(current | treename);
{assert : name in current node printed}
inorder |current|.right}
{assert : names in all nodes in right subtree of current node
have been printed in lexical order}
end
end
2. preorder traversal
procedure preorder{current:treepointer};
begin
if current<> nil then
begin
writeln {current|.treename);
{assert : name in current node printed}
preorder {current|.left};
{assert : names in all nodes in lefft subtree of current node have
preorder{current|.right}
{assert : names in all nodes in right substree of current node
have been printed in preorder order}
end
end
3.posttorder traversal
posttorder traversal{current:treepointer};
begin
if current<> nil then
begin
writeln {current|.treename);
{assert : name in current node printed}
preorder {current|.left};
{assert : names in all nodes in lefft subtree of current node have
preorder{current|.right}
{assert : names in all nodes in right substree of current node
have been printed in preorder order}
end
end
begin
if current<> nil then
begin
writeln {current|.treename);
{assert : name in current node printed}
preorder {current|.left};
{assert : names in all nodes in lefft subtree of current node have
preorder{current|.right}
{assert : names in all nodes in right substree of current node
have been printed in preorder order}
end
end