#21_Doubly linked list
#include <stdio.h> #include <stdlib.h> //Doubly linked list struct node { int data; struct node * prev; struct node * next; }; void traverse ( struct node * head ) { struct node * ptr = head ; while (ptr->next != NULL ) { printf ( " %d " , * ptr); ptr = ptr->next; } printf ( " %d " , * ptr); while (ptr->prev != NULL ) { printf ( " %d " , * ptr); ptr = ptr->prev; } printf ( " %d \n " , * ptr); } struct node * insertion_1 ( struct node * head , int data ) { //Insertion of node at head in doubly linked list struct node * newNode = ( struct node * ) malloc ( sizeof ( struct node )); newNode->data = data ; newNode->next = head ; head ->prev = newNode; head = newNode; newNode->prev = NULL ; return head ; } s