Algorithm 1 Preorder traversal

procedure preorder (T : ordered root tree)
r := root of T
list r
for each child c of r from left to right
begin
	T(c) := subtree with c as its root
	Preorder (T(c))
end