Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Queue Data Structure Implementation in C++, Exercises of Data Structures and Algorithms

The implementation of a queue data structure using c++. The user can perform dequeue, enqueue, display, and exit operations on the queue. The program checks for queue underflow and overflow conditions before performing the respective operations.

Typology: Exercises

2011/2012

Uploaded on 07/30/2012

dhanvantari
dhanvantari 🇮🇳

2

(2)

48 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download Queue Data Structure Implementation in C++ and more Exercises Data Structures and Algorithms in PDF only on Docsity! #include<conio.h> #include<iostream.h> int rear=-1,front=-1,queue[10],max=10; void main (void) { int choice,input; clrscr(); cout<<"Enter one of the following options\n\n\t--> To Dequeue enter: 1\n\t--> To enqueue enter: 2\n\t--> To display enter: 3\n\t--> To exit enter: 4\n"; cin>>choice; while (choice!=4) { switch (choice) { case 1: if(front==-1 || rear==-1) { cout<<"The queue is empty\n"; } else { for (int i=front;i<rear;i++) { queue[i]=queue[i+1]; } rear--; } break; case 2: if (rear==(max-1)) { cout<<"The queue is full\n"; } else { if (front==-1) { front=0; } cout<<"Enter the number you want to enqueue: "; cin>>input; rear++; queue[rear]=input; } break; case 3: cout<<"\n"; for(int i=0;i<=rear;i++) { cout<<queue[i]<<" "; }cout<<"\n"; break; default: docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved