You are on page 1of 16

Linked list

Deletion of singly linked list

Submitted by- Akash kumar


Submitted to- Mitendar Arya sir
 Linked list
 Difference between linked list and Arrays
 Advantages of linked list
 Disadvantages of linked list
 Deletion of node from start
 Deletion of node list from end
 Deletion of node list from specified position
 Linked list is a dynamic data structure
i.e., size can grow/shrink
 Elements of linked list are called node
 Self referential data type
 Insertion /removal of node Is Allowed
 Random access of elements is not Allowed
 Dynamic data structure
 Efficient memory utilization
 Easy insertion/Deletion operation
 More memory
 Random access is time consuming
 Singly linked list
 Doubly linked list

 Singly linked list:-


 each node has one link part
 each link part contains the address of the next
node in the list
 Link part of the last node contains NULL value
which signifies the end of the node
Deleting a node at the front of the list Called
dequeue. Header in the list will contain the address
of the first node. In that address part of the header
node we have to delete the address of the first node
and replace it with the address of the second node.
This will result in the deletion of the first node in
the list.
 Steps:-
1) Break the pointer connection
2) Re-connect the node
3) Delete the node

StructNodeDeletefromstart(structNode**,int);
StructNodeDeletefromstart(structNode**start,int num);
{
if(*start!=NULL)
{ structNode *store;
store=*start;
start = storelink;
free(store);
}
else
printf(“linked list is empty”);
}
After deletion first node from linked list
Steps:-
1. Break the pointer connection
2. Set previous node pointer to Null
3. Delete the node

StructNodedeletefromend(structNode**,int);
StructNodedeletefromend(structNode**,start,int num)
{
if(*start!=NULL)
{ struct node * store;
store =*start;
while(storelink!=NULL)
{ store = storelink;
}
}
After deletion node from end in linked list
Steps :-
 Set previous node pointer to next node
 Break node pointer connection
 Delete the node
Void Deletefrommiddle(structNode**,int,int);
Void Deletefrommiddle(structNode**,start,int num,int count Node)
{
if(*start!=NULL)
{ structNode*Start;
structNode*trav;
store=*start;
trav=*start;
store=storelink;
while(storelink!=count Node)
{ store=storelink;
trav=travlink;
}
travlink=storelink;
Free(store);
}
Else
Printf”linked list is empty”);
}
After deletion node from middle

You might also like