

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive overview of the queue data structure, focusing on its implementation using arrays. It explains the basic concepts of queues, including enqueue and dequeue operations, and illustrates these with c++ code examples. The document also covers applications of queues in cpu scheduling and synchronization, offering practical insights into their use in computer science. Exercises are included to reinforce understanding and encourage hands-on learning, making it a valuable resource for students studying data structures and algorithms. This lab document is useful for university students.
Typology: Lecture notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


#include
if (front==-1) front=0; rear++; Queue[rear]=item; } } int dequeue() { if(isEmpty()) { cout<<"Queue Underflow \n"; return - 1; } else { int item=Queue[front]; front++; return item; } } void traverse() { if(isEmpty()) cout<<"Queue is Empty \n"; else { for(int i=front;i<=rear;i++) cout<<Queue[i]<<" "; } cout<<endl; } void main() { int ch,item; front=rear=-1; cout<<"Enter Queue Size"; cin>>size; Queue=new int [size]; while(true) { cout<<"***************************************\n"; cout<<"1) Insert element to Queue \n"; cout<<"2) Delete element from Queue \n"; cout<<"3) Display all the elements of queue \n"; cout<<"4) Exit \n"; cout<<"***************************************\n"; cin>>ch; switch (ch) { case 1 : cout<<"Enter the item:"; cin>>item; enqueue(item); break; case 2 : cout<<dequeue()<<" Deleted from the Queue \n"; break;