home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!pdh
- From: pdh@netcom.com (Phil Howard )
- Subject: Re: Printing out trees
- Message-ID: <1992Nov16.081021.9316@netcom.com>
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- References: <gezTJc_00VQsAo9Vpl@andrew.cmu.edu> <BxG3py.LoA@cck.coventry.ac.uk> <UezhlN_00VQs4rjqFN@andrew.cmu.edu>
- Date: Mon, 16 Nov 1992 08:10:21 GMT
- Lines: 36
-
- Richard Dale Romero <rickr+@CMU.EDU> writes:
-
- >No, that's not really what I meant--I meant in a formatted way
- >so that I could tell what the child-parent relations were...
-
- What I have done (while testing an implementation of my variation of
- the AVL balanced binary tree) is to print deeper nodes more indented.
-
- I don't have that particular code handly at the moment, but it was
- essentially much the same as the previously posted code excepted that
- an addition argument was passed along AND INCREMENTED AT EACH LEVEL.
- That value controlled a loop to putc() that number of blanks at the
- front of each line.
-
- BIG trees are going to be hard to visualize graphically no matter what
- you do.
-
-
- >Regardless it will print out a node such that its direct children
- >are on the line directly below it, *every* item in the left
- >sub-tree appears to the left of the current node, and *every* item
- >in the right sub-tree appears to the right of the current node.
-
- Mine printed the left children first, the parent in between, and the
- right children last. Since I was dealing with the sorted order of
- the tree I needed to look at it that way.
-
- Either way, the leaf nodes will always be adjacent to their parents,
- but intermediate nodes won't be because the leaf nodes are in the way,
- except for the initial descent in your logic. That is if I understood
- you correctly.
- --
- /***********************************************************************\
- | Phil Howard --- KA9WGN --- pdh@netcom.com | "The problem with |
- | depending on government is that you cannot depend on it" - Tony Brown |
- \***********************************************************************/
-