cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/26/15:05:26.1

From: seth AT kansmen DOT com (Seth Jones)
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,comp.programming
Subject: Re: Question: Linked lists and classes: Self initiation
Message-ID: <MPG.118e56767e41ca9c9896f7@client.sw.news.psi.net>
References: <3720BE52 DOT 6E86A8C4 AT xoommail DOT com> <3720D21C DOT 9617323B AT atlantis DOT stortek DOT com> <MPG DOT 118aa8dd6a37fb039896f6 AT client DOT sw DOT news DOT psi DOT net> <37213049 DOT 1471831 AT news-server>
Organization: Kansmen
X-Newsreader: MicroPlanet Gravity v2.10
Lines: 30
Date: Mon, 26 Apr 1999 18:45:01 GMT
NNTP-Posting-Host: 38.170.72.106
NNTP-Posting-Date: Mon, 26 Apr 1999 14:45:01 EDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <37213049 DOT 1471831 AT news-server>, -Gadget-nospam-
@vic.bigpond.net.au says...
> A linked list is an iterative structure, not a recursive one.
> A tree structure is recursive.

You've never programmed in LISP, have you?
The typical C++ definition of a linked list is something like

struct node
{
   type value;
   node *next;
};
If that's not a recursive definition, I don't know what is.
In fact it is _also_ an iterative structure, because iteration and tail-
recursion are functionally equivalent.

> As was mentioned earlier, this makes an interesting stunt (stunt?!),
> but is a bit like peeling oranges with a potato peeler. There are much
> better and more efficient ways, so why make life difficult.
> You wouldn't rewrite the code 'for (n=0 ; n<100; n++)' as a recursive
> routine... or would you?

Only if I was rewriting it in LISP, or some other functional language. 
C++ generally handles iteration more efficiently than recursion (I think 
I mentioned that before). 

Seth Jones


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019