SlideShare a Scribd company logo
1 of 8
Introduction
Queue is a linear Data Structure in which the
operations are performed based on FIFO (First In
First Out) principle.
In a Queue always the Insertion operation is done at
“rear” and Deletion operation is done at “front”.
In a Queue sequence of elements entered into the
queue is same as the sequence of elements leave
the queue.
Queue ADT
Definition
• Queue is a linear Data Structure in which the operations
are performed based on FIFO (First In First Out) principle.
Fields
• rear – used to store the position of insertion
• front – used to store the position of deletion
• size – used to store the size of the queue
• element – used to store the value to be inserted
Functions
• enQueue(element) – to insert into queue
• deQueue( ) – to delete from queue
• display( ) – to display all elements in queue
Condition
• Rear >= size – Queue is full
• Front == rear – Queue is empty
class Queue
{
int *Q, front, rear, size;
public:
Queue()
{
cout<<“Enter the Queue size:”;
cin>>size;
Q = new int[size];
front=rear=-1;
}
void qInsert(int);
void qDelete();
void qDisplay();
}
f = front
r = rear
f = r = -1
Q
Queue is EMPTY
0 1 2 3 4 5 . . . SIZE-1
When the object of Queue class is created it allocates memory
and executes the constructor
Insertion
Q
enQueue( int element )
{
if( rear != size-1)
{
rear ++;
Q[rear] = element;
}
}
else
cout<< “Queue is full !!!”;
0 1 2 3 4 5 6 7 8 9
10 20 30 40
Deletion
Q
deQueue( )
{
if( front != rear )
{
front ++;
Cout<<“nElement removed : ”<<Q[front];
}
}
else
cout<< “Queue is empty !!!”;
0 1 2 3 4 5 6 7 8 9
10 20 30 40
Display
Q
if( front != rear )
{
for(int i=front+1; i<=rear, i++)
cout<<Q[front]<<“t”;
}
}
else
cout<< “Queue is empty !!!”;
0 1 2 3 4 5 6 7 8 9
10 20 30 40
display( )
{

More Related Content

What's hot (20)

Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
QUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING CQUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING C
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Detalied information of queue
Detalied information of queueDetalied information of queue
Detalied information of queue
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 
Queues-and-CQueue-Implementation
Queues-and-CQueue-ImplementationQueues-and-CQueue-Implementation
Queues-and-CQueue-Implementation
 
Queue-Data Structure
Queue-Data StructureQueue-Data Structure
Queue-Data Structure
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
 
Queue
QueueQueue
Queue
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Queue
QueueQueue
Queue
 
Queue
QueueQueue
Queue
 
Queues
QueuesQueues
Queues
 
Queues in C++
Queues in C++Queues in C++
Queues in C++
 
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queue
 
Priority queues
Priority queuesPriority queues
Priority queues
 
Team 6
Team 6Team 6
Team 6
 
Queue
QueueQueue
Queue
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 

Viewers also liked

Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queuesBuxoo Abdullah
 
Queue data structure
Queue data structureQueue data structure
Queue data structureanooppjoseph
 
Sem3 nivel1 francia romano terra
Sem3 nivel1 francia romano terraSem3 nivel1 francia romano terra
Sem3 nivel1 francia romano terramoncayo1986
 
Data structure lecture 9
Data structure lecture 9Data structure lecture 9
Data structure lecture 9Kumar
 
358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9sumitbardhan
 
المحاضرة الثامنة: تراكيب البيانات الطابور
المحاضرة الثامنة: تراكيب البيانات الطابورالمحاضرة الثامنة: تراكيب البيانات الطابور
المحاضرة الثامنة: تراكيب البيانات الطابورMahmoud Alfarra
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queueRojan Pariyar
 
Data Structure -List Stack Queue
Data Structure -List Stack QueueData Structure -List Stack Queue
Data Structure -List Stack Queuesurya pandian
 
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureZidny Nafan
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
List Data Structure
List Data StructureList Data Structure
List Data StructureZidny Nafan
 

Viewers also liked (17)

Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queues
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Data structure
Data structureData structure
Data structure
 
Sem3 nivel1 francia romano terra
Sem3 nivel1 francia romano terraSem3 nivel1 francia romano terra
Sem3 nivel1 francia romano terra
 
Data structure lecture 9
Data structure lecture 9Data structure lecture 9
Data structure lecture 9
 
Queues
QueuesQueues
Queues
 
358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9
 
المحاضرة الثامنة: تراكيب البيانات الطابور
المحاضرة الثامنة: تراكيب البيانات الطابورالمحاضرة الثامنة: تراكيب البيانات الطابور
المحاضرة الثامنة: تراكيب البيانات الطابور
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queue
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
 
Data Structure -List Stack Queue
Data Structure -List Stack QueueData Structure -List Stack Queue
Data Structure -List Stack Queue
 
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
 

Similar to Queue by rajanikanth (20)

QUEUE.pptx
QUEUE.pptxQUEUE.pptx
QUEUE.pptx
 
Unit – iv queue
Unit – iv    queueUnit – iv    queue
Unit – iv queue
 
QUEUES
QUEUESQUEUES
QUEUES
 
Queue
QueueQueue
Queue
 
Queues & ITS TYPES
Queues & ITS TYPESQueues & ITS TYPES
Queues & ITS TYPES
 
Lecture 2d queues
Lecture 2d queuesLecture 2d queues
Lecture 2d queues
 
4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data Structure
 
Queue(lecture8).pptx
Queue(lecture8).pptxQueue(lecture8).pptx
Queue(lecture8).pptx
 
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
 
6 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart36 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart3
 
Circular queue
Circular queueCircular queue
Circular queue
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
 
Queue
QueueQueue
Queue
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
Queue oop
Queue   oopQueue   oop
Queue oop
 
Queue data structures and operation on data structures
Queue data structures and operation on data structuresQueue data structures and operation on data structures
Queue data structures and operation on data structures
 

Recently uploaded

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Queue by rajanikanth

  • 1.
  • 2. Introduction Queue is a linear Data Structure in which the operations are performed based on FIFO (First In First Out) principle. In a Queue always the Insertion operation is done at “rear” and Deletion operation is done at “front”. In a Queue sequence of elements entered into the queue is same as the sequence of elements leave the queue.
  • 3. Queue ADT Definition • Queue is a linear Data Structure in which the operations are performed based on FIFO (First In First Out) principle. Fields • rear – used to store the position of insertion • front – used to store the position of deletion • size – used to store the size of the queue • element – used to store the value to be inserted Functions • enQueue(element) – to insert into queue • deQueue( ) – to delete from queue • display( ) – to display all elements in queue Condition • Rear >= size – Queue is full • Front == rear – Queue is empty
  • 4. class Queue { int *Q, front, rear, size; public: Queue() { cout<<“Enter the Queue size:”; cin>>size; Q = new int[size]; front=rear=-1; } void qInsert(int); void qDelete(); void qDisplay(); }
  • 5. f = front r = rear f = r = -1 Q Queue is EMPTY 0 1 2 3 4 5 . . . SIZE-1 When the object of Queue class is created it allocates memory and executes the constructor
  • 6. Insertion Q enQueue( int element ) { if( rear != size-1) { rear ++; Q[rear] = element; } } else cout<< “Queue is full !!!”; 0 1 2 3 4 5 6 7 8 9 10 20 30 40
  • 7. Deletion Q deQueue( ) { if( front != rear ) { front ++; Cout<<“nElement removed : ”<<Q[front]; } } else cout<< “Queue is empty !!!”; 0 1 2 3 4 5 6 7 8 9 10 20 30 40
  • 8. Display Q if( front != rear ) { for(int i=front+1; i<=rear, i++) cout<<Q[front]<<“t”; } } else cout<< “Queue is empty !!!”; 0 1 2 3 4 5 6 7 8 9 10 20 30 40 display( ) {