Hi,
i know linked lists. But what are double-linked lists?
thnxq
Hi,
i know linked lists. But what are double-linked lists?
thnxq
a linked list that can go backwards as well as forwards and requires an extra pointer or two to acheive this....although i have never used it so far.
hoping to be certified (programming in c)
here's the news - I'm officially certified.
That is correct, In a singly linked list you only point in one direction, where the doubly linked list points to nodes before and after itself. Which makes insertion into a list a little easier
Code:typedef struct node NODE; /* Node for a singly linked list */ struct node { int data; NODE *next; }; /* Node for a doubly linked list */ struct node { int data; NODE *prior; NODE *next; };
Last edited by foniks munkee; 04-15-2002 at 08:03 PM.
it also makes it a lot easier and quicker to free up memory on a large scale, like when you quit your program, you can simply do somethin like:
only disadvantage of double linked lists is the extra memory it uses and the extra few instructions needed to add items into the list but quiet often you'll find that its worth it for the convenience.Code:while(tempptr->next != NULL) { tempptr=tempptr->next; free(tempptr->prev); } free(tempptr);