SINGLE LINKED LIST

The single list is a structure node with data field and a pointer to struct .
node declaration is
struct node
{
int data;
struct node *next;
};
The operations on a single linked list
push(int data)
delete (int data)
print(struct *head )
PUSH operation:
Here data can be inserted into a linked list at any position ,
1.At initial position
2.At end
3.At middle position
DELETE operation
Here data can be deleted from linked list
1.At front
2.At end
3.In the middle
Print :
Using a single linked list ,the data can be printed from first node to last node.
This article tells about push operations
Pushfront:
This function is used to push data at the front
void Pushfront(int data)
{
struct node *temp;
temp=(node *)malloc(sizeof(node));
temp->data=data;
temp->next=NULL;
temp->next=head;
head=temp;
}
The explanation about push front is the new temp structure created for this data ,the next variable of the temp structure is assigned with head value and head value is reassigned to temp structure.
void PushLast(int data)
{
struct node *temp,*temp1;
temp1=head;
temp=(node *)malloc(sizeof(node));
temp->data=data;
temp->next=NULL;
while(temp1!=NULL)
temp1=temp1->next;
temp->next=temp;
}
The explanation about push last is the new temp structure created for this data ,a temporary variable is considered to point to last node,this can be done using a while loop ,the last pointer variable next value is stored with new structure address.
void push_at_middle(int data ,int l)
{
struct node *temp,*temp1;
int i=0;
temp1=head;
temp=(node *)malloc(sizeof(node));
temp->data=data;
temp->next=NULL;
while(i
{
temp1=temp1->next;
i++;
}
temp->next=temp1->next;
temp1->next=temp;
}

The loop is same as pushing at the last , but the temporary is moved until l position and assign the next value of temp variable's next and temp1 variable next variable value is temp1