Posts

Showing posts from December, 2020

DOUBLE LINKED LIST IMPLEMENTATION

Image
welcome to yocoding, a place where you can find what you need, if not comment what you need.   CODE :  #include<stdio.h> #include<conio.h> #include<stdlib.h> struct Node {   int data;   struct Node *prev,*next; }; struct Node *head=NULL; void insert_beg(int d) {     struct Node *p;     p= (struct Node*)malloc(sizeof(struct Node));     p->data=d;     p->prev=NULL;     if(head == NULL)     {        p->next = NULL;        head=p;     }     else     {        p->next=head;        head->prev=p;        head=p;     } } void insert_end(int d) {    struct Node *p;    p=(struct Node*)malloc(sizeof(struct Node));    p->data=d;    p->next = NULL;    if(head == NULL)    {       p->prev=NULL;       head=p;    }    else    {       struct Node *q = head;       while(q-> next != NULL)          q = q-> next;       q-> next = p;       p-> prev = q;    }   } void insert_pos(int d,int pos) {    int i;    struct Node *p;    p=(struct Node*)malloc(sizeof(