annie12, on 11 September 2013 - 04:54 AM, said:
i used the link pointer so the tmp pointer knows where it to stop. i remove the link pointer but i dont understand what should i do in the while loop to make it teminate
The next pointer of tail should be (will be) 0/null.
61 tmp=tmp->nxtptr;
So you can check for tmp equal null.
Concepts
When you have an empty list head and tail will equal zero/null.
When you have one item/node in the list head and tail will point to the same node. When you add a node to the end, then you should update tail but head will still point to the same/previous node.
With more than one nodes already in the list, the code will be the same - only changing the tail pointer and leaving the head pointer as is.
The node pointed to by head will have a previous pointer set to null.
The node pointed to by tail will have a next pointer set to null.

New Topic/Question
Reply




MultiQuote

|