Queues using Linked list in Data Structures

Blog Author


Published Date

21st September, 2018




  • Share this blog :

Queues using Linked list

It configures storage (using arrays), queues where harder to manipulate then were stacks. It causes difficulties to handle full queues and empty queues. It is for queues that linked storage really comes into its own The linked implementation has two advantages over the array implementation (1) it is faster locations for insertion and deletion are same at the back and at the front and 2) it wastes no space Linked queues are just as easy to handle as are linked stacks.   45   Program: Program to implement queue using linked list : # include<stdio.h> #include<conio.h> #include<stdio.h> struct node { int data; struct node *next; }; struct node *front=NULL ;*rear; void insertion() { int els; struct node *new node; new node=(struct node *)malloc(sizeof(struct node)); printf(“Enter data for new node: ”); scanf(“%d”,&ele); newnode 7data=ele; newnode 7next=NULL; if(front==NULL) { front=new node; rear=front; } else { rear7 next= new code; rear= new node; } } void deletion() { struct node *temp; if(front==NULL) printf(“QUEUE underflow”); else { temp=front; front=front 7 next; printf(“Deleted element is : %d \n”, temp 7 data); free(temp); } } void display() { struct node *ptr; if(front===NULL) printf(“queue is empty”); else { printf(“elements of queue are :”); for(ptr=front; ptr!=NULL;ptr=ptr7next); printf(“%5d”,ptr7 data); } } void main() { int ch; clrscr(); do { printf(“1. INSERTION \n”); printf(“2. DELETION \n”); printf(“3. DISPLAY \n”); printf(“4.EXIT \n”); printf(“Enter U r choice :”); scanf(“%d”,&ch); switch(ch) { case1: insertion(); break; case2: deletion(); break; case3: display(); break; case 4: exit(0); } } while(ch<=4) getch(); }                            

About Author


Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .

Related Blogs

Write For Us