Monday, 29 August 2011

Insertion new node at the end of the Linked List

Insertion new node at the end of the Linked List

Insertion new node at the end.

1. Declare neccessary variables.
2. Create an empty node and assign it to node pointer p.
3. Insert the data item to info field of newly created node,
     i.e. p->info = data;
4. Assign NULL to the next field of newly created node
    i.e. p->next = NULL;
5. If list == NULL;
         then list = p;
     Else
         Find the last node of the current list say l.
         then l->next = p;
6. For next insertion, goto step 2.

No comments:

Post a Comment