case the new node is inserted at the end case the new node is inserted after given node case the new node is inserted before given node inserting node at the beginning of doubly linked list consider the doubly linked list shown in fig suppose we want to add new node with data as the first node of the list then the following changes will be done in the linked list start allocate memory for the new node and initialize its data part to and prev field to null add the new node before the start node now the new node becomes the first node of the list start figure inserting new node at the beginning of doubly linked list step if avail null write overflow go to step [end of ifstep set new_node avail step set avail avail -next step set new_node -data val step set new_node -prev null step set new_node -next start step set start -prev new_node step set start new_node step exit figure algorithm to insert new node at the beginning figure shows the algorithm to insert new node at the beginning of doubly linked list in step we first check whether memory is available for the new node if the free memory has exhaustedthen an overflow message is printed otherwiseif free memory cell is availablethen we allocate space for the new node set its data part with the given val and the next part is initialized with the address of the first node of the listwhich is stored in start nowsince the new node is added as the first node of the listit will now be known as the start nodethat isthe start pointer variable will now hold the address of new_node inserting node at the end end of doubly linked list consider the doubly linked list shown in fig suppose we want to add new node with data as the last node of the list then the following changes will be done in the linked list start allocate memory for the new node and initialize its data part to and its next field to null take pointer variable ptr and make it point to the first node of the list start,ptr move ptr so that it points to the last node of the list add the new node after the node pointed by ptr start figure inserting new node at the end of doubly linked list ptr