Professional Documents
Culture Documents
deletionindoublylinkedlist
deletionindoublylinkedlist
deletionindoublylinkedlist
The following steps are followed, to delete a node at the beginning of the list:
void delete_beg()
{
Struct node *temp;
if(start == NULL)
{
printf("\n
n Empty list");
getch();
return ;
}
else
{
temp = start;
start = start ->
> right;
start ->
> left = NULL;
free(temp);
}
}
Deleting a node at the end:
The following steps are followed to delete a node at the end of the list:
void delete_last()
{
Struct node *temp;
if(start == NULL)
{
printf("\n
n Empty list"); getch(); return ;
}
else
{
temp = start;
while(temp ->> right != NULL)
temp = temp -> > right;
temp -> left ->
> right = NULL;
free(temp);
temp = NULL;
}
}
Deleting a node at Intermediate location:
loc
The following steps are followed, to delete a node from an intermediate location in the list (List must
contain more than two nodes).