Function to insert node in a linked list
void insert ( Node * * root , int item ) { Node * ptr , * temp ; temp = new Node ; temp -> data = item ; temp -> next = NULL ; if ( * root == NULL ) * root = temp ; else { ptr = * root ; while ( ptr -> next != NULL ) ptr = ptr -> next ; ptr -> next = temp ; } }