Posts

Showing posts with the label QUEUE

Queue Using Linked List

Image
Queue :-  In  programming , a queue is a  data structure  in which elements are removed in the same order they were entered. This is often referred to as FIFO (first in, first out). Program #include <iostream> #include <conio.h> #define MAX 10 using namespace std; struct queue     {      int data;      queue *prev, *next;     }*ctr, *temp, *start=NULL; void push(); void show(); void pop(); int  main() { int count=0;       while(1)     {                   cout <<"MAIN MENU\n" ;                 cout <<"\tPress 1 for PUSH \n" ;                 cout <<"\tPress 2 for SHOW \n" ;                 cout <<"\tPress 3 for POP \n" ;             ...

QUEUE USING ARRAY ....

Image
#include<iostream> #include<conio.h> #define MAX 10 using namespace std; void insert(); void delet(); void display(); int queue[MAX], rear=-1, front=-1, item; int main() { int ch; do  {   cout<<"Press\n1. Insert\n2. Delete\n3. Display\n4. Exit\nAns.\t";   cin>>ch;     switch(ch)   {   case 1:     insert();     break;     case 2:       delet();     break;     case 3:       display();     break;     case 4:               return 0;     default:       cout<<"\n\nInvalid entry. Please try again...\n";   } } while(1); getch(); } void insert() { if(rear == MAX-1)   cout<<"\n\nQueue is full.\n\n"; else {   ...