Depth(tree T, node v)
(1) if T.isRoot(v)
(2) return 0
(3) else
(4) return(1 + depth(T,v.parent()));
Height(T) (1) for each v in T.positions() do (2) if T.isExternal(v) then (3) h = max(h, depth(T,v)) (4) return(h)
height2(T,v)
(1) if T.isExternal(v) then
(2) return(0)
(3) else
(4) h = 0
(5) foreach w in T.children(v) do
(6) h = max(h, height2(T,w))
(7) return(h+1)
PrintPreorder(v)
(1) print v.element
(2) foreach w in children(v)
(3) PrintPreorder(w)
PrintInorder(v) (1) PrintInorder(firstchild(v)) (2) print v.element (3) foreach w in children(v)-firstchild(v) (4) PrintInorder(w)
PrintPostorder(v)
(1) foreach w in children(v)
(2) PrintPostorder(w)
(3) print v.element