Procedure to insert in node in doubly linear linked list.
voidinsert(struct node *ptr,int data,int pos) {// Creating a new nodestruct node *newNode; newNode = (struct node *)malloc(sizeof(struct node));newNode -> data = data;// If node is to be inserted at first positionif (pos ==1) {if (head ==NULL) {newNode -> prev =NULL;newNode -> next =NULL; head = newNode; } else {newNode -> prev =NULL;newNode -> next = head; head = newNode; } }// If node is to be inserted in any other positionelse {for (int i =0; i < pos -2; i++) { ptr =ptr -> next; }newNode -> next =ptr -> next;newNode -> prev = ptr;// Check if next node is availableif (ptr -> next) {ptr -> next -> prev = newNode; }ptr -> next = newNode; }