From: myknees AT aol DOT com (Myknees) Newsgroups: comp.os.msdos.djgpp Subject: Re: Linked lists Date: 30 Mar 1998 23:39:05 GMT Lines: 30 Message-ID: <1998033023390501.SAA29429@ladder01.news.aol.com> NNTP-Posting-Host: ladder01.news.aol.com References: <3 DOT 0 DOT 5 DOT 32 DOT 19980329185251 DOT 007a4430 AT vip DOT cybercity DOT dk> Organization: AOL http://www.aol.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <3 DOT 0 DOT 5 DOT 32 DOT 19980329185251 DOT 007a4430 AT vip DOT cybercity DOT dk>, "Nils Emil P. Larsen" writes: >Can anyone show me (or tell me where to find) a good example of practical >using of linked lists? I really don't understand what they a for, but I >think they are important! This question is not really djgpp specific -- a bit off topic for this newsgroup, but while we're talking about it... Linked lists are for situations where it is critical to be able to insert and delete elements from an ordered series of an indefinite number of elements. e.g. (maybe) a list of structs containing employee data arranged in alphabetical order, when you only need to use the structs in alphabetical order. Since the way you access the data is by going down the chain of elements (nodes) in order, it is very slow if you have a long list where you won't be using the elements in order. An alternative is to have a dynamically-allocated array of pointers to the structs. That's much faster for random access and doesn't cost more in memory, since the structs don't need to contain a pointer to the next struct. Of course, when you use an array you lose the ability to insert and delete elements easily and efficiently. Kochan's excellent _Topics in C Programming_ has a brief intro to linked lists. There is another book with more in-depth coverage -- I believe its title is (sorry I'm not absolutely sure) _Advanced C_ and the author has also written books on PC graphics. --Ed (Myknees)