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 ptr start step repeat step while ptr -data !num step set ptr ptr -next [end of loopstep set new_node -next ptr step set new_node -prev ptr -prev step set ptr -prev new_node step set ptr -prev -next new_node step exit figure shows the algorithm to insert new node after given node in doubly linked list in step we take pointer ptr and initialize it with start that isptr now points to the first node of the linked list in the while loopwe traverse through the linked list to reach the node that has its value equal to num we need to reach this node because the new node will be inserted after this node once we reach this nodewe change the next and prev fields in such way that the new node is inserted after the desired node inserting node before given node in doubly linked list consider the doubly linked list shown in fig figure algorithm to insert new node before suppose we want to add new node with value given node before the node containing before discussing the changes that will be done in the linked listlet us first look at the algorithm shown in fig in step we first check whether memory is available for the new node in step we take pointer variable ptr and initialize it with start that isptr now points to the first node of the linked list in the while loopwe traverse through the linked list to reach the node that has its value equal to num we need to reach this node because the new node will be inserted before this node once we reach this nodewe change the next and prev fields in such way that the new node is inserted before the desired node start allocate memory for the new node and initialize its data part to take pointer variable ptr and make it point to the first node of the list startptr move ptr further so that it now points to the node whose data is equal to the value before which the node has to be inserted start add the new node in between the node pointed by ptr and the node preceding it ptr ptr start start figure inserting new node before given node in doubly linked list deleting node from doubly linked list in this sectionwe will see how node is deleted from an already existing doubly linked list we will take four cases and then see how deletion is done in each case