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