procedure preorder (tnode)begin if nil then ( )preorder( left)preorder( rightend end preorder procedure inorder (tnode)begin if nil then inorder( left) ( )inorder( rightend end inorder procedure postorder (tnode)begin if nil then postorder( left)postorder( right) (tend end postorder note that the pointer is passed as value parameter this expresses the fact that the relevant entity is the reference to the considered subtree and not the variable whose value is the pointerand which could be changed in case were passed as variable parameter an example of tree traversal routine is that of printing treewith appropriate indentation indicating each node' level binary trees are frequently used to represent set of data whose elements are to be retrievable through unique key if tree is organized in such way that for each node iall keys in the left subtree of are less than the key of iand those in the right subtree are greater than the key of ithen this tree is called search tree in search tree it is possible to locate an arbitrary key by starting at the root and proceeding along search path switching to node' left or right subtree by decision based on inspection of that node' key only as we have seenn elements may be organized in binary tree of height as little as log(nthereforea search among items may be performed with as few as log(ncomparsions if the tree is perfectly balanced obviouslythe tree is much more suitable form for organizing such set of data than the linear list used in the previous section as this search follows single path from the root to the desired nodeit can readily be programmed by iterationprocedure locate (xintegertnode)nodebegin while ( nil( key xdo if key then : right else : left end endreturn end locate the function locate(xtyields the value nilif no key with value is found in the tree with root as in the case of searching listthe complexity of the termination condition suggests that better solution may existnamely the use of sentinel this technique is equally applicable in the case of tree the use of pointers makes it possible for all branches of the tree to terminate with the same sentinel the resulting structure is no longer treebut rather tree with all leaves tied down by strings to single anchor point