In: Computer Science
a.
b. statement to remove operation
for any node to be deleted other than front and end.
select node to be delete lets its name be node,
point to node->next ->prev = node->prev ;
and also point
node->prev->next = node->next;
and free(node) from memory.
pseudocode for above operation is
void delete(Node head,Node node)
{
if (head == NULL || node == NULL)
{
return;
}
if (head ==node)
{
head = node->next;
}
if (node->next != NULL)
{
node->next->prev = node->prev;
}
if (node->prev != NULL)
{
node->prev->next = node->next;
}
free(node); // remove from memory
}
c. since each operation of shifting nodes is done in constant time , i.e. it does not depends on length of double linked list , hence its complexity is O(1).