SOURCE FILE: inorderRecursive


RECURSIVE ALGORITHM FOR DOING AN IN-ORDER TRAVERSAL OF A BINARY
TREE

This example illustrates that sometimes a recursive method of
solving a problem quite simple.

PROCEDURE InOrder (p : NodePtr) ;
BEGIN
  IF   p <> nil (* if this tree is not empty *)
  THEN BEGIN
  
         InOrder(p^.left) ; (* process the left subtree in-order *)
	 

	    (* Process the node that p points to: print the
	       contents, or whatever. *)

	 Process(p);

	 
         InOrder(p^.right) ;(* process the right subtree in-order *)
	 
       END
END (* That's all! *)