home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16178 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.2 KB  |  31 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!rexago8!aa
  3. From: aa@rexago8.uucp (Adam Andrews)
  4. Subject: Re: To Recurse or NOT to recurse?
  5. Message-ID: <1992Nov8.220448.25437@rexago8.uucp>
  6. Organization: Summit Information Systems
  7. References: <1992Nov6.185136.8055@netcom.com> <BxBFrw.2p9@portal.hq.videocart.com>
  8. Date: Sun, 8 Nov 1992 22:04:48 GMT
  9. Lines: 20
  10.  
  11. dfuller@portal.hq.videocart.com (Dave Fuller) writes:
  12. >sjs@netcom.com (Stephen Schow) writes:
  13. >: ... SHould I use recursion
  14. >: to search down through the list for the last node, or should I use a while
  15. >: loop?  What or the pro's and con's of each?
  16. >
  17. >Recursion would, however, be the choice if you need to do an operation that
  18. >needs to keep a state constant. Menuing functions are good examples of this.
  19. >although there probably are exceptions, the only good time for recursion
  20. >is when code will be reused and needs to keep each state of its instance
  21. >completely independant of the others.
  22.  
  23. Another good use of recursion is the traversal of a tree structure, as 
  24. opposed to a linked list.
  25.  
  26.  
  27. -- 
  28. Adam Andrews                "When the going gets weird, we get even weirder."
  29. uunet!rexago8!aa or aa@rexago8.UUCP       e-mail only to aa@summitis.com
  30.