Algorithm 5 Tree Traversal Recursive

Require: a tree TT using left-child, right-sibling representation

Ensure: print all keys appearing in TT

1:procedure PrintTree(xx)

2:if x==NILx == NIL then

3:return

4:end if

5:print x.keyx.key

6:y=x.lefty = x.left-childchild

7:while yNILy \ne NIL do

8:PrintTree(yy)

9:y=y.righty = y.right-siblingsibling

10:end while

11:end procedure

12:

13:PrintTree(T.rootT.root)