home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16578 < prev    next >
Encoding:
Text File  |  1992-11-15  |  2.0 KB  |  47 lines

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