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