Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   C: Header Cell/Node in a Double Circularly Linkeded List (http://www.go4expert.com/forums/c-header-cell-node-double-circularly-t5991/)

Jose Francisco 23Aug2007 08:21

C: Header Cell/Node in a Double Circularly Linkeded List
 
Hey guys!

I need some assistance in creating my header node or cell in a double circularly linked list. I have come up with the single linked list header node:

Code:

list_ptr createHeader (void){
 list_ptr L;
 L = (list_ptr) malloc(sizeof(list));
 L->next = NULL;
 return L;
}

However, I'm having difficulty in coding the header previous, which in fact would instantly point to the last node in my double circularly linked list. How do I go about adding that code to my createHeader function?

Is it as simple as stating the following:
Code:

L->prev = NULL;
Am I missing something?

Thanks again!
Regards,
Jose :)

shabbir 23Aug2007 08:32

Re: C: Header Cell/Node in a Double Circularly Linkeded List
 
It should be assigned when you have the second node in question or you can point to the head node itself whichever is useful to you. I would prefer assigning it to the head node.

Jose Francisco 24Aug2007 19:57

Re: C: Header Cell/Node in a Double Circularly Linkeded List
 
Hey shabbir!

Thanks for the prompt reply. I am not really understanding your reply. How do we go about implementing that in my createHeader function?

Quote:

It should be assigned when you have the second node in question
Do you meant it will be assigned automatically?

Quote:

you can point to the head node itself
Code:

L->prev=L;
Is that what you mean?

Thank you for your time,
Jose :)

shabbir 24Aug2007 22:12

Re: C: Header Cell/Node in a Double Circularly Linkeded List
 
For the second node It will not be automatic but you need to be doing that but the second option I was saying is what you have understood.


All times are GMT +5.5. The time now is 09:47.