
nodes linked listed and such
Quote:
>I am trying to figure out an exercise that wants me to delete 3 types of
>nodes, head node, tail node and middle node of a linked list. It makes no
>sense to me (newbie)
>the setup is
>typedef struct node
>{
> int value; /* value of node */
> struct node next; /* points to next node in list */
> struct node previous /* points to previous node in list */
> }NodeRec;
First of all, next and previous are not pointers, but they should be.
Quote:
>typedef NodeRec *node_ptr;
>The foward pointers follow the node values in sorted order from smallest to
>largest. The backwards pointer points to each nodes predecessor as
>determined by the sorted ordering
>I need to create a function test = remove(item,head,tail);
>I've been working on this type of example for days and I must be really
>stupid because I just don't understand it. I'd appreciate any answers
The best way to tackle this assignment is to write a function that
does the following:
1. Accept the (value of the) node to delete.
2. If you have only the value , Walk through through the list to find
the node
3. If the node has a previous node, let this previous node point to
the next node.
4. If the node has a next node, let this next node point to the
previos node.
5. delete the node.
You have to call this function once for every node you want to delete.
Quote:
Bart v Ingen Schenau
--