brian@ukma.UUCP (Brian Sturgill) (12/15/84)
This is Wirth's algorithm for tree printing from Data Strutures + Algorithms = Program's. This version is written in Modula 2. PROCEDURE PrintTree(t : treeptr; h : CARDINAL); (* Print out Expression Tree *) (* h is current height of tree *) (* From main program call as PrintTree(root,0) *) VAR i :CARDINAL; BEGIN IF t # NIL THEN PrintTree(t^.l,h+1); FOR i := 1 TO h DO WriteString(' ') END; WriteChar(outsd,t^.data); WriteLn; PrintTree(t^.r,h+1); END END PrintTree; ----------------------------------------- Brian Sturgill University of Kentucky Graduate School (606) 257-4613 /------- Arpa-Net unmvax----\ / research >---/------------/-------- anlams!ukma!ukgs!brian boulder---/ / decvax!ucbvax -/ (or cbosgd!hasmed!qusavx!ukma!ukgs!brian) For arpa-net, anlams has the name ANL-MCS. (i.e. "ukma!ukgs!brian@ANL-MCS"). We have been having intermittent problems with this address though. Subject: Re: tree printing algorithm wanted Newsgroups: net.wanted.sources This is Wirth's algorithm for tree printing from Data Strutures + Algorithms = Program's. This version is written in Modula 2. PROCEDURE PrintTree(t : treeptr; h : CARDINAL); (* Print out Expression Tree *) (* h is current height of tree *) (* From main program call as PrintTree(root,0) *) VAR i :CARDINAL; BEGIN IF t # NIL THEN PrintTree(t^.l,h+1); FOR i := 1 TO h DO WriteString(' ') END; WriteChar(outsd,t^.data); WriteLn; PrintTree(t^.r,h+1); END END PrintTree; ----------------------------------------- Brian Sturgill University of Kentucky Graduate School (606) 257-4613 /------- Arpa-Net unmvax----\ / research >---/------------/-------- anlams!ukma!ukgs!brian boulder---/ / decvax!ucbvax -/ (or cbosgd!hasmed!qusavx!ukma!ukgs!brian) For arpa-net, anlams has the name ANL-MCS. (i.e. "ukma!ukgs!brian@ANL-MCS"). We have been having intermittent problems with this address though.