The document provides information about queues in C++. It defines a queue as a first-in, first-out (FIFO) data structure where elements are inserted at the rear and deleted from the front. The document discusses implementing queues using arrays and linked lists, with operations like insertion, deletion, and handling overflow/underflow. Example C++ programs are provided to demonstrate queue operations and implementations using arrays and linked lists.
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
Stack and its Applications : Data Structures ADTSoumen Santra
Stack is an Abstract Data Type (ADT), Last in First out (LIFO) concept.
Features of Stack: Abstract Data Type (ADT)
C implementations of Stack's Functions like push(), pop(), isEmpty(), isOverflow(), peep()
Stack Applications like Tower of Hanoi, Infix to Postfix Conversion, Postfix Evaluation, Parenthesis Checking etc.
Diagramatic Representation of Tower of Hanoi, Infix to Postfix Conversion & Postfix Evaluation
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
Stack and its Applications : Data Structures ADTSoumen Santra
Stack is an Abstract Data Type (ADT), Last in First out (LIFO) concept.
Features of Stack: Abstract Data Type (ADT)
C implementations of Stack's Functions like push(), pop(), isEmpty(), isOverflow(), peep()
Stack Applications like Tower of Hanoi, Infix to Postfix Conversion, Postfix Evaluation, Parenthesis Checking etc.
Diagramatic Representation of Tower of Hanoi, Infix to Postfix Conversion & Postfix Evaluation
Queues
a. Concept and Definition
b. Queue as an ADT
c. Implementation of Insert and Delete operation of:
• Linear Queue
• Circular Queue
For More:
https://github.com/ashim888/dataStructureAndAlgorithm
http://www.ashimlamichhane.com.np/
Data Structure- Stack operations may involve initializing the stack, using it and then de-initializing it. Apart from these basic stuffs, a stack is used for the following two primary operations −
PUSH, POP, PEEP
Queues
a. Concept and Definition
b. Queue as an ADT
c. Implementation of Insert and Delete operation of:
• Linear Queue
• Circular Queue
For More:
https://github.com/ashim888/dataStructureAndAlgorithm
http://www.ashimlamichhane.com.np/
Data Structure- Stack operations may involve initializing the stack, using it and then de-initializing it. Apart from these basic stuffs, a stack is used for the following two primary operations −
PUSH, POP, PEEP
Queue is a Linear list which has two ends, one for insertion of elements and other for deletion of elements. The first end is called 'Rear' and the later is called 'Front'. Elements are inserted from Rear End and Deleted from Front End. Queues are called First In First Out (FIFO) List, since the first element in a queue will be the first element out of the queue. In other words, the order in which the elements enter a queue is the order in which they leave.
In Batch Processing the jobs are "Queued up" as they are read in and executed, one after another in the order they were received. This ignores the possible existence of priorities.
An ordered collection of items from which items may be deleted from one end called the front and into which items may be inserted from other end called rear is known as Queue.
It is a linear data structure.
It is called the First In First Out (FIFO) list. Since in queue, the first element will be the first element out.
Stack and Queue.pptx university exam preparationRAtna29
Queues and stacks are dynamic while arrays are static. So when we require dynamic memory we use queue or stack over arrays. Stacks and queues are used over arrays when sequential access is required. To efficiently remove any data from the start (queue) or the end (stack) of a data structure
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
2. INTRODUCTION TO QUEUE
DEFINITION:
A stack is a data structure that provides temporary storage of data in such
a way that the element stored first will be retrieved first.
This method is also called FIFO – First In First Out.
EXAMPLE:
In real life we can think of queue as a queue of vehicles waiting at the petrol
pump, people waiting at the bus stop for the bus etc. The first person to
enter the queue is the first one to leave the queue. Similarly last person to
join the queue is the last person to leave the queue.
3. OPERATIONS ON QUEUE
A queue is a linear data structure.
It is controlled by two operations: insertion and deletion.
Insertion operation takes place from the rear end of the queue and
deletion operation takes place from the front end of the queue.
Insertion operation adds an element to the queue.
Deletion operation removes an element from the queue.
There are two variables FRONT and REAR. FRONT points to the
beginning of the filled queue and takes care of deletion operation. REAR
points to the end of the queue and takes care of insertion operation.
These two operations implement the FIFO method .
5. QUEUE AS AN ARRAY
Array implementation of Queue uses
an array to store data
an integer type variable usually called the FRONT,
which points to the beginning of the array and an
integer variable REAR, which points to the end of
the filled array.
30
20
10
2
4
3
2
1
0REAR
0
FRONT
6. INSERTION OPERATION
Initially when the queue is empty, FRONT and REAR can have any
integer value other than any valid index number of the array. Let
FRONT = -1; REAR=-1;
The first element in the empty queue goes to the 0th position of the
array and both FRONT and REAR are initialized to value 0.
After this every insertion operation increase the REAR by 1 and
inserts new data at that particular position.
As arrays are fixed in length, elements can not be inserted beyond
the maximum size of the array. Pushing data beyond the maximum
size of the queue (i.e. when REAR = MAX SIZE -1) results in “data
overflow”.
8. DELETE OPERATION
The delete operation deletes the very first item from the queue.
Any attempt to delete an element from the empty queue (when
FRONT+REAR=-1) results in “data underflow” condition.
Each time the deletion operation is performed, the FRONT
variable is decremented by 1.
When there is only one element in the queue, deletion operation
of that element makes the queue empty and both FRONT and
REAR will be assigned the value -1.
10. PROGRAMTO ILLUSTRATE OPERATIONS ON QUEUE
AS AN INTEGER ARRAY
#include<iostream.h>
#include<conio.h>
#define size 4
class queue
{
int data[size];
int front,rear;
public:
queue()
{ front=-1; rear=-1; }
void insert();
void deletion();
};
void queue::insert()
{ if(rear==size-1)
{ cout<<"n queue is full";
return;
}
else if(rear == -1)
{ rear++;
front++; }
else
rear++;
cout<<"Enter Data : ";
cin>>data[rear]; }
void queue::deletion()
{
if(front==-1)
{ cout<<"n Queue is empty";
return;
}
cout<<data[front]<<"
deleted"<<endl;
if(front==rear)
{ front=-1;rear=-1; }
else
front++; }
void display()
{ for (int i=front;i<=rear; i++)
cout<< data[rear]; }
void main()
{
queue q;
int ch;
do
{
cout<<"n1. Insertn2. Deleten3.
Displayn4.QuitnEnterChoice(1-3) ";
cin>>ch;
switch(ch)
{
case 1: q.insert();break;
case 2: q.deletion();break;
case 3. q.display();
}
}while(ch!=3); }
11. PROGRAMTO ILLUSTRATE OPERATIONS ON QUEUE
AS AN ARRAY OF OBJECTS
#include<iostream.h>
#include<conio.h>
struct item
{ int ino;
char name[20]; };
class queue
{
item data[4];
int front,rear;
public:
queue()
{ front=-1; rear=-1; }
void insert();
void deletion();
};
void queue::insert()
{ if(rear==size-1)
{ cout<<"n queue is full";
return; }
else if(rear == -1)
{ rear++;
front++; }
else
rear++;
cout<<"Enter Data : ";
cin>>data[rear].ino>>
data[rear].name; }
void queue::deletion()
{
if(front==-1)
{ cout<<"n Queue is empty";
return; }
cout<<data[front].ino<<"
deleted"<<endl;
if(front==rear)
{ front=-1;rear=-1; }
else
front++; }
void display()
{ for (int i=front;i<=rear; i++)
cout<< data[rear]].ino<<
data[rear].name; }
void main()
{
queue q;
int ch;
do
{
cout<<"n1. Insertn2. Deleten3.
Displayn4.QuitnEnterChoice(1-3) ";
cin>>ch;
switch(ch)
{ case 1: q.insert();break;
case 2: q.deletion();break;
case 3. q.display();
}
}while(ch!=3); }
12. APPLICATIONS OF QUEUE
A queue is an appropriate data structure on which information is
stored and then retrieved in FIFO order.The applications of queue
are as follows:
Queues find their use in CPU scheduling, printer spooling,
message queuing, computer networks etc.
In time sharing system queues help in scheduling of jobs.
13. DISADVANTAGE OF NORMAL QUEUE
The queue as an array suffers from one major drawback.
As arrays are fixed in size, elements can not be inserted beyond
the maximum size of the array, even though in reality there
might be empty slots in the beginning of the queue.
REAR
30 40 50 60
0 1 2 3 4 5
2 5FRONT
In this example, queue is considered
as full although there are two empty
spaces in the beginning of the queue.
14. CIRCULAR QUEUE AS AN ARRAY
Array implementation of Circular Queue uses
an array to store data
an integer type variable usually called the FRONT, which
points to the beginning of the filled array and an integer
variable REAR, which points to the end of the filled
array.
NOTE: When the number of additions makes REAR equal to the size
of the array, the next element is inserted in the first slot provided it is
free. Circular queue is full when all the slots of the array are
occupied.
50
40
30
60
2
4
3
2
1
0
REAR
0
FRONT
15. OPERATIONS ON CIRCULAR QUEUE
A queue is a linear data structure.
It is controlled by two operations: insertion and deletion.
Insertion operation takes place from the rear end of the queue and
deletion operation takes place from the front end of the queue.
There are two variables FRONT and REAR. FRONT points to the
beginning of the queue and takes care of deletion operation. REAR
points to the end of the queue and takes care of insertion operation.
If REAR reaches the end of the queue then the next insertion
operation makes REAR=0 provided FRONT is not 0.
If the FRONT reaches the end of the queue then the next deletion
operation makes FRONT=0 provided there are more elements in the
queue.
16. CIRCULAR QUEUE: INSERTION OPERATION
Initially when the queue is empty, FRONT and REAR can have any
integer value other than any valid index number of the array. Let
FRONT = -1; REAR=-1;
The first element in the empty queue goes to the 0th position of
the array and both FRONT and REAR are initialized to value 0.
After this every insertion operation increases the REAR by 1 and
inserts new data at that particular position.
If REAR reaches the end of the queue then the next insertion
operation makes REAR=0 provided FRONT is not 0.
The queue is full when REAR=FRONT +1 or (FRONT=0 and
REAR=MAX-1). Insertion at this point results in “data overflow”.
18. CIRCULAR QUEUE:DELETE OPERATION
The delete operation deletes the very first item from the queue.
Any attempt to delete an element from the empty queue(when
FRONT+REAR=-1) results in “data underflow” condition.
Each time the deletion operation is performed, the FRONT
variable is decremented by 1.
When there is only one element in the queue, deletion operation
of that element makes the queue empty and both FRONT and
REAR will be assigned the value -1.
When FRONT reaches the end of the queue then the next
deletion operation makes FRONT = 0.
20. PROGRAMTO ILLUSTRATE OPERATIONS ON CIRCULAR QUEUE
#include<iostream.h>
#include<conio.h>
#define size 4
class cqueue
{
int data[size];
int front,rear;
public:
cqueue()
{ front=-1;rear=-1; }
void insert();
void remove(); };
void cqueue::insert(int num)
{ if(rear==size-1&&
front==0 || front==rear+1)
{ cout<<"nCircular
queue is full";
return;
}
else if(rear==-1)
{ rear++;
front++; }
else if(rear==size-1)
rear=0;
else
rear++;
cout<<"Enter Data : ";
data[rear]=num;
}
void cqueue::remove()
{
if(front==-1)
{
cout<<"n Circular
Queue is empty";return;
}
cout<<data[front]<<"
deleted"<<endl;
if(front==rear)
{ front=-1;rear=-1; }
else if(front==size-1)
front=0;
else
front++;
}
void cqueue::disp()
{if(front<rear)
for(int i= front;i<=rear;
i++)
cout<<data[i];
else
{for(int i=front;i<=size-1;
i++)
cout<<data[i];
for(int i= 0;i<=rear; i++)
cout<<data[i]; }}
void main()
{
cqueue cq;
int ch;
do
{
cout<<"n1. Insert n2.
Removen3. Displayn 4.
Quit n Enter Choice(1-4) ";
cin>>ch;
switch(ch)
{ case 1:
cq.insert();break;
case 2:
cq.remove();break;
case 3: cq.disp(); }
}while(ch!=4);}
21. QUEUE AS A LINKED LIST
Linked list implementation of queue uses:
A linked list to store data
A pointer FRONT pointing to the beginning of the queue and a pointer REAR
pointing to the end of the queue.
NOTE: Each node of a queue as a linked list has two parts : data part and link part and
is created with the help of self referential structure.
The data part stores the data and link part stores the address of the next node of the
linked list.
FRONT
NODE
DATA LINK
REAR
23. PROGRAMTO ILLUSTRATE OPERATIONS ON QUEUE
AS A LINKED LIST : Explanation
#include<iostream.h>
#include<conio.h>
struct node
{
int data;
node *next;
};
class queue
{
node *rear,*front; // front point to the beginning of the queue and rear points to the end of the queue
public:
queue()
{ rear=NULL;front=NULL;} // Initializes front and rear to NULL
void qinsert();
void qdelete();
void qdisplay();
};
Self Referential Structure:These are special structures which
contains pointers to themselves.
Here, next is a pointer of type node itself.
Self Referential structures are needed to create Linked Lists.
24. PROGRAMTO ILLUSTRATE OPERATIONS ON QUEUE
AS A LINKED LIST : Explanation
void queue::qinsert()
{
node *temp; // pointer of type node
temp=new node; // new operator will create a new
//node and address of new node
// is stored in temp
cout<<"Data :";
cin>>temp->data; // adding data in the node
temp->next=NULL; // because new node is always
// added at the end
if(rear==NULL) // if queue is empty, new node
{ rear=temp; // becomes the first node and
front=temp; // both front and rear will point to
} //it
else
{ rear->next=temp; // If queue is not empty ,last
rear=temp; // node will contain address
} // of new node and rear will
} // point to new node
void queue::qdelete()
{
if(front!=NULL) // if queue is not empty
{ node *temp=front; // temp is a pointer
//containing address of
// first node
cout<<front->data <<"deleted n";
front=front->next; // front will now contain
// address of second node
delete temp; // delete operator will delete the node
// stored at temp
if(front==NULL) /*if front become NULL after
deletion, it means that there was only one node
in the queue and deletion of that node will
queue empty */
rear=NULL; }
else
cout<<“empty Queue “;}