Posts

Showing posts with the label linked list

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)    {   ...

IMPLEMENTATION OF QUEUE BY LINKEDLIST : C PROGRAM

Image
  Hey there ,welcome to yocoding. Here is the code for queue by linked list in C programming language. Program code : #include<stdio.h> #include <stdlib.h> struct node {     int data;     struct node *next; }; struct node *rear=NULL,*front=NULL; void enque(int d) {     struct node *p;     p=(struct node *)malloc(sizeof(struct node));     p->data=d;     if(front==NULL)     {         p->next=NULL;         front=p;         rear=p;         return;     }     rear->next=p;     p->next=NULL;     rear=p;     return; } void deque() {     struct node *temp;     if(front==NULL)         printf("queue is empty.\n");     else if(front==rear){         printf("deleted element %d.\n",front->data);   ...

Implementation of Stack with Singly Linked List : C Program

Image
  Here is the code for implementation of stack with singly linked list : program code : #include<stdio.h> #include <stdlib.h> struct node {     int data;     struct node *next; }; struct node *top=NULL; void push(int d) {     struct node *newnode=(struct node*)malloc(sizeof(struct node));     newnode->data=d;     newnode->next=NULL;     if(top==NULL)     {         top=newnode;     }     else{         newnode->next=top;         top=newnode;     }     printf("\ndata %d has been pushed (entered to stack).",d); } void pop() {     struct node *p,*temp=top;     if(temp=NULL)     {         printf("\nstack is empty.");         return;     }     p=top;     top=top->next;     free(p);   ...