Monday, 29 August 2011

Insertion node at front single linked list


Algorithm for adding an element  (data) to the front of the list list.
1. Declare and initialize necessary variables
2. Create an empty node and assign it to node pointer p.
3. Take input data and assign it to data field of new node
     i.e. p->data = data;
4. Set next field. i.e. p->next = list;
5. Set list pointer to p i.e. list = p;
6. For next insertion operation, goto step 2



 


1. Linked list  

No comments:

Post a Comment