
Removing a NODE for good (double linked lists)
Quote:
> I think I'm getting the basic idea of double-linked lists but as Alex
> Krol mentioned I haven't used free() on the NODE after re-pointing the
> pointers. Below seems to work and I'm hoping that it's correct but
> when do you free the NODE?
Hi Richard Zilavec,
You free a node when you no longer need it and it is no longer
referenced. So if you decide to remove a certain element from the list,
you set a pointer to the element to be removed first. Then you do the
actual removing, ie. reorder the list so does not point to the element
any more. *Afterwards* you call the "free()" function for the element.
This will make the pointer invalid, because it now points to illegal
unallocated memory.
Quote:
> This way of thinking is totally new to me, I find it extremely
> challenging but a lot of fun.
That's what I always say: programming is fun !
Quote:
> I try to read all the articles in this
> group hoping to one day understand what everbody is talking about.
That's a commendable goal, but hard to manage. There's a lot coming in
per day. For starters you can skip everything headed "How to kil MS".
You'll probably work out some more filtering rules yourself ;-)
Quote:
> Actually, I'm starting to understand more and more each day.
That's good. Have you read the FAQ yet ? It will give you a one month
dose of knowledge in a day.
You can get the FAQ at http://www.eskimo.com/~scs/C-faq/top.html or
at ftp://rtfm.mit.edu/pub/usenet/comp.lang.c/C-FAQ-list and it gets
posted to this newsgroup and to news.answers regularly (at the
beginning of each month).
Quote:
> How much
> do you need to know before trying for a job in this field? Maybe
> become a Junior programmer and enjoy what I'm doing for a livin.....
Really a lot. Here in Germany i took a programmer education, which
took 3 years. But with the education certificate I had no problem in
finding a job.
Quote:
> /* Trees are next in my book :) */
If you've mastered doubly linked lists, trees are a piece of cake. It's
exactly the same data structure for binary trees, simply with other
names for the node pointers, and of course with a different concept
behind the whole thing.
Stephan
(initiator of the campaign against grumpiness in c.l.c)