Doubly linked list insertion
insert node at the beginning of a Doubly linked list

use code from the create and display nodes and getnode function to assign data click here
- create a function inserbeg( )
- create a *newnode pointer
- call getnode( ) function to assign data to newnode

4.link newnode->next address to head pointer

5.link head->prev address to newnode

6.initialize head pointer to the newnode

code to insert node at the beginning of a Doubly linked list
void dllinsertbeg()
{
node *newnode;
newnode = getnode();
if(head == NULL)
head = newnode;
else
{
newnode -> next = head;
head -> prev = newnode;
head = newnode;
}
}
insert node at the ending of a Doubly linked list

use code from the create and display nodes and getnode function to assign data click here
- create a function inserbeg( )
- create a newnode ,temp pointer
- call getnode( ) function to assign data to newnode,initialize head for temp

4.move temp pointer to the last node by replacing temp with next node in the doubly linked list ( temp = temp -> next) until the condition (temp -> next != NULL),so the temp will be pointed to the last node when the condition fails

5.link next address of temp to newnode (temp -> next = newnode)

6.link previous of newnode node to temp node (newnode -> previous = temp)

code to insert node at the ending of a Doubly linked list
void dllinsertend()
{
node *newnode, *temp;
newnode = getnode();
if(head == NULL)
head = newnode;
else
{
temp = head;
while(temp -> next != NULL)
temp = temp -> next;
temp -> next = newnode;
newnode -> prev = temp;
}
}