SlideShare a Scribd company logo
DATA STRUCTURE
Chapter 7: Queue
Prepared & Presented by
Mr. Mahmoud R. Alfarra
2011-2012
College of Science & Technology
Dep. Of Computer Science & IT
BCs of Information Technology
http://mfarra.cst.ps
Out Line
 What is Queue data structure?
 EnQueue operation
 DeQueue operation
 Clear the Queue
 Print all data of Queue
 Search about data
 Queue Class
 Types of Queue
2
What is Queue data
structure?
 Queues are used to prioritize operating system
processes and to simulate events in the real
world, such as teller lines at banks and the
operation of elevators in buildings.
 A queue is a data structure where data enters at
the rear of a list and is removed from the front of
the list.
 Queues are an example of a first-in, first-out
(FIFO) data structure.
3
Mohame
d
Ghadeer
Ali
Ahmed
Hussam
Rear Front
Queue Operations
 The two primary operations involving queues
are adding a new item to the queue and
removing an item from the queue.
 The operation for adding a new item is called
Enqueue, and the operation for removing an
item from a queue is called Dequeue.
 The other primary operation (The Peek
method) to perform on a queue is viewing the
beginning
 item.
4
What is Queue data
structure?
5
Element of Queue
6
‫البيانات‬ ‫تراكيب‬ ‫مساق‬
‫إعداد‬ ‫العلمية‬ ‫المادة‬
/
‫أ‬
.
‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬
 Exactly as linked list and stack …
1- Element of Queue
(customer)
7
‫البيانات‬ ‫تراكيب‬ ‫مساق‬
‫إعداد‬ ‫العلمية‬ ‫المادة‬
/
‫أ‬
.
‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬
1. class Customer {
2. public int parts;
3. public int amount;
4. public String name;
5. public Customer next;
6. public Customer() {
7. parts = 0;
8. amount = 0;
9. name = "no name"; }
10. public Customer(int parts, int amount, String name) {
11. this.parts = parts;
12. this.amount = amount;
13. this.name = name; } }
2- Class Queue of customer
8
‫البيانات‬ ‫تراكيب‬ ‫مساق‬
‫إعداد‬ ‫العلمية‬ ‫المادة‬
/
‫أ‬
.
‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬
1. class QueueOfCustomer {
2. public Customer Front;
3. public Customer Rear;
4. public int length;
5. public QueueOfCustomer()
6. {
7. Front = null;
8. Rear = null;
9. length = 0;
10. }
11.}
EnQueue Operation
9
Mohame
d
Ghadeer
Ali
Rear Front
Ahmed
New item
1
2
X
EnQueue Operation
10
1. public void InQueue(Customer addCus)
2. {
3. Customer newc = addCus;
4. if (Front == null)
5. {
6. Front = newc;
7. Rear = newc;
8. newc.next = null;
9. }
10. else
11. {
12. newc.next = Rear;
13. Rear = newc;
14. }
15. length++;
16. Console.WriteLine("The new Object is added: "+length);
17. }
DeQueue operation
11
Mohame
d
Ghadeer
Ali
Rear Front
Ahmad
current
DeQueue operation
12
1. public void DeQueue() {
2. if (Front == null)
3. Console.WriteLine("The Queue is Empty!!");
4. else
5. {
6. Customer current;
7. Customer pre_current = Rear;
8. for (current = Rear; current.next != null; current =
current.next)
9. pre_current = current;
10. Front = pre_current;
11. length--;} }
Peek Operation
13
Front.name
front.salary
…
Front
Peek Operation
14
‫البيانات‬ ‫تراكيب‬ ‫مساق‬
‫إعداد‬ ‫العلمية‬ ‫المادة‬
/
‫أ‬
.
‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬
1. public void Peek()
2. {
3. if (Front == null)
4. Console.WriteLine("The Queue is empty");
5. else
6. Console.WriteLine("The Data of the first is:n "+
7. Front.name +"n "+Front.amount+"n "+Front.parts);
8. }
Clear the Queue
15
1. public void Clear()
2. {
3. if (Rear == null)
4. Console.WriteLine("The Queue is Empty!!");
5. else
6. Rear = null;
7. Length = 0;
8. }
Print all data of Queue
16
Mohame
d
Ghadeer
Ali
Rear Front
Ahmed
current current current current
Print all data of Queue
17
‫البيانات‬ ‫تراكيب‬ ‫مساق‬
‫إعداد‬ ‫العلمية‬ ‫المادة‬
/
‫أ‬
.
‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬
1. public void PrintAll()
2. {
3. Customer current;
4. for (current = Rear; current != null; current = current.next)
5. {
6. Console.WriteLine(" ========================== ");
7. Console.WriteLine("The Data of the element is:n " +
8. current.name + "n " + current.amount + "n " + current.parts);
9. Console.WriteLine(" ========================== ");
10. }
11. }
Search about data
18
Mohame
d
Ghadeer
Ali
Rear Front
Ahmed
current current current current
Search about data
19
‫البيانات‬ ‫تراكيب‬ ‫مساق‬
‫إعداد‬ ‫العلمية‬ ‫المادة‬
/
‫أ‬
.
‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬
1. public void SearchByAmount(int amount)
2. {
3. Customer current = Rear;
4. bool flag = false;
5. while (current != null)
6. {
7. if (current.amount == amount)
8. {
9. flag = true;
10. break;
11. }
12. current = current.next;
13. }
14. if (flag == true)
15. Console.WriteLine("The element is exist!! ");
16. else
17. Console.WriteLine("The element does not exist!! ");
18. }
Queue Class
 Class of Queue available in collection space of
.Net.
20
Practice : develop a full
application using class of Queue
Types of Queue
 Linear queue
 Circular queue
 Double ended queue
Thank You …
22
Remember that: question is the key of knowledge
Ahl Eljanna 

َ
‫ه‬َ‫ن‬َ
‫و‬ ٍ
‫َّات‬‫ن‬َ
‫ج‬ ِ
‫ِف‬ َ
‫ني‬ِ
‫َّق‬‫ت‬ُ
‫ْم‬‫ل‬‫ا‬ َّ
‫ن‬ِ‫إ‬
ٍ
‫ر‬
)::(
ِ
‫ع‬ ٍ
‫ق‬ْ
‫د‬ِ
‫ص‬ ِ
‫د‬َ
‫ع‬ْ
‫ق‬َ
‫م‬ ِ
‫ِف‬
َ
‫د‬ْ‫ن‬
ٍ
‫ر‬ِ
‫د‬َ‫ت‬ْ
‫ق‬ُ
‫م‬ ٍ
‫يك‬ِ‫ل‬َ
‫م‬
)::(
23

More Related Content

What's hot (20)

Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
3 Array operations
3   Array operations3   Array operations
3 Array operations
Mahmoud Alfarra
 
Data Structure Project File
Data Structure Project FileData Structure Project File
Data Structure Project File
Deyvessh kumar
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
Divya Kumari
 
Stack and queue
Stack and queueStack and queue
Stack and queue
CHANDAN KUMAR
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
Divya Kumari
 
Queue oop
Queue   oopQueue   oop
Queue oop
Gouda Mando
 
Searching&sorting
Searching&sortingSearching&sorting
Searching&sorting
Radhe Syam
 
Queue
QueueQueue
Queue
Sonali Soni
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
Muhammad khan
 
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORYCS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
Radha Maruthiyan
 
Lab 1
Lab 1Lab 1
Lab 1
rimshailyas1
 
Stack queue
Stack queueStack queue
Stack queue
Harry Potter
 
CodeFest 2014. Axel Rauschmayer — JavaScript’s variables: scopes, environment...
CodeFest 2014. Axel Rauschmayer — JavaScript’s variables: scopes, environment...CodeFest 2014. Axel Rauschmayer — JavaScript’s variables: scopes, environment...
CodeFest 2014. Axel Rauschmayer — JavaScript’s variables: scopes, environment...
CodeFest
 
Main ds manual
Main ds manualMain ds manual
Main ds manual
Vivek Kumar Sinha
 
Stack and queue
Stack and queueStack and queue
Stack and queue
LavanyaJ28
 
Array within a class
Array within a classArray within a class
Array within a class
AAKASH KUMAR
 
Queues
QueuesQueues
Queues
Syed Zaid Irshad
 
Arrays
ArraysArrays
Arrays
archikabhatia
 
Sample Paper 2 Class XI (Computer Science)
Sample Paper 2 Class XI (Computer Science)Sample Paper 2 Class XI (Computer Science)
Sample Paper 2 Class XI (Computer Science)
Poonam Chopra
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
Data Structure Project File
Data Structure Project FileData Structure Project File
Data Structure Project File
Deyvessh kumar
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
Divya Kumari
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
Divya Kumari
 
Searching&sorting
Searching&sortingSearching&sorting
Searching&sorting
Radhe Syam
 
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORYCS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
Radha Maruthiyan
 
CodeFest 2014. Axel Rauschmayer — JavaScript’s variables: scopes, environment...
CodeFest 2014. Axel Rauschmayer — JavaScript’s variables: scopes, environment...CodeFest 2014. Axel Rauschmayer — JavaScript’s variables: scopes, environment...
CodeFest 2014. Axel Rauschmayer — JavaScript’s variables: scopes, environment...
CodeFest
 
Stack and queue
Stack and queueStack and queue
Stack and queue
LavanyaJ28
 
Array within a class
Array within a classArray within a class
Array within a class
AAKASH KUMAR
 
Sample Paper 2 Class XI (Computer Science)
Sample Paper 2 Class XI (Computer Science)Sample Paper 2 Class XI (Computer Science)
Sample Paper 2 Class XI (Computer Science)
Poonam Chopra
 

Similar to Chapter 7: Queue data structure (20)

Basic Terminologies of Queue...Basic operations on Queue
Basic Terminologies of Queue...Basic operations on QueueBasic Terminologies of Queue...Basic operations on Queue
Basic Terminologies of Queue...Basic operations on Queue
arpitasen55
 
Understanding the Concepts and Applications of Stack and Queue
Understanding the Concepts and Applications of Stack and QueueUnderstanding the Concepts and Applications of Stack and Queue
Understanding the Concepts and Applications of Stack and Queue
madhuakash830
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
Mekk Mhmd
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
Dr.Shweta
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Sriram Raj
 
Basic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptxBasic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptx
LakshmiSamivel
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Afaq Mansoor Khan
 
DS ppt1.pptx.c programing. Engineering. Data structure
DS ppt1.pptx.c programing. Engineering. Data structureDS ppt1.pptx.c programing. Engineering. Data structure
DS ppt1.pptx.c programing. Engineering. Data structure
dibyajyotijena05
 
Chapter 7 ds
Chapter 7 dsChapter 7 ds
Chapter 7 ds
Hanif Durad
 
Queue
QueueQueue
Queue
Zaid Shabbir
 
Queue
QueueQueue
Queue
Zaid Shabbir
 
Queue
QueueQueue
Queue
Shaista Qadir
 
10 -queues using array_07485555555510.ppt
10 -queues using array_07485555555510.ppt10 -queues using array_07485555555510.ppt
10 -queues using array_07485555555510.ppt
nailapp2023
 
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdnsLab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
playstore9ha
 
Data structure
Data structureData structure
Data structure
ashutoshsingh1011
 
Queue using array with all the diagrams ppt.pptx
Queue using array with all the diagrams ppt.pptxQueue using array with all the diagrams ppt.pptx
Queue using array with all the diagrams ppt.pptx
pwstudent403
 
The Queue in Data structure and algorithm
The Queue in Data structure and algorithmThe Queue in Data structure and algorithm
The Queue in Data structure and algorithm
SourajitMaity1
 
Queue
QueueQueue
Queue
Ayaz Akhtar
 
Queue
QueueQueue
Queue
pooja kumari
 
Basic Terminologies of Queue...Basic operations on Queue
Basic Terminologies of Queue...Basic operations on QueueBasic Terminologies of Queue...Basic operations on Queue
Basic Terminologies of Queue...Basic operations on Queue
arpitasen55
 
Understanding the Concepts and Applications of Stack and Queue
Understanding the Concepts and Applications of Stack and QueueUnderstanding the Concepts and Applications of Stack and Queue
Understanding the Concepts and Applications of Stack and Queue
madhuakash830
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
Mekk Mhmd
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Sriram Raj
 
Basic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptxBasic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptx
LakshmiSamivel
 
DS ppt1.pptx.c programing. Engineering. Data structure
DS ppt1.pptx.c programing. Engineering. Data structureDS ppt1.pptx.c programing. Engineering. Data structure
DS ppt1.pptx.c programing. Engineering. Data structure
dibyajyotijena05
 
10 -queues using array_07485555555510.ppt
10 -queues using array_07485555555510.ppt10 -queues using array_07485555555510.ppt
10 -queues using array_07485555555510.ppt
nailapp2023
 
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdnsLab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
playstore9ha
 
Queue using array with all the diagrams ppt.pptx
Queue using array with all the diagrams ppt.pptxQueue using array with all the diagrams ppt.pptx
Queue using array with all the diagrams ppt.pptx
pwstudent403
 
The Queue in Data structure and algorithm
The Queue in Data structure and algorithmThe Queue in Data structure and algorithm
The Queue in Data structure and algorithm
SourajitMaity1
 
Ad

More from Mahmoud Alfarra (20)

Computer Programming, Loops using Java - part 2
Computer Programming, Loops using Java - part 2Computer Programming, Loops using Java - part 2
Computer Programming, Loops using Java - part 2
Mahmoud Alfarra
 
Computer Programming, Loops using Java
Computer Programming, Loops using JavaComputer Programming, Loops using Java
Computer Programming, Loops using Java
Mahmoud Alfarra
 
Chapter 10: hashing data structure
Chapter 10:  hashing data structureChapter 10:  hashing data structure
Chapter 10: hashing data structure
Mahmoud Alfarra
 
Chapter9 graph data structure
Chapter9  graph data structureChapter9  graph data structure
Chapter9 graph data structure
Mahmoud Alfarra
 
Chapter 8: tree data structure
Chapter 8:  tree data structureChapter 8:  tree data structure
Chapter 8: tree data structure
Mahmoud Alfarra
 
Chapter 2: array and array list data structure
Chapter 2: array and array list  data structureChapter 2: array and array list  data structure
Chapter 2: array and array list data structure
Mahmoud Alfarra
 
Chapter 0: introduction to data structure
Chapter 0: introduction to data structureChapter 0: introduction to data structure
Chapter 0: introduction to data structure
Mahmoud Alfarra
 
3 classification
3  classification3  classification
3 classification
Mahmoud Alfarra
 
8 programming-using-java decision-making practices 20102011
8 programming-using-java decision-making practices 201020118 programming-using-java decision-making practices 20102011
8 programming-using-java decision-making practices 20102011
Mahmoud Alfarra
 
7 programming-using-java decision-making220102011
7 programming-using-java decision-making2201020117 programming-using-java decision-making220102011
7 programming-using-java decision-making220102011
Mahmoud Alfarra
 
6 programming-using-java decision-making20102011-
6 programming-using-java decision-making20102011-6 programming-using-java decision-making20102011-
6 programming-using-java decision-making20102011-
Mahmoud Alfarra
 
5 programming-using-java intro-tooop20102011
5 programming-using-java intro-tooop201020115 programming-using-java intro-tooop20102011
5 programming-using-java intro-tooop20102011
Mahmoud Alfarra
 
4 programming-using-java intro-tojava20102011
4 programming-using-java intro-tojava201020114 programming-using-java intro-tojava20102011
4 programming-using-java intro-tojava20102011
Mahmoud Alfarra
 
3 programming-using-java introduction-to computer
3 programming-using-java introduction-to computer3 programming-using-java introduction-to computer
3 programming-using-java introduction-to computer
Mahmoud Alfarra
 
2 programming-using-java how to built application
2 programming-using-java how to built application2 programming-using-java how to built application
2 programming-using-java how to built application
Mahmoud Alfarra
 
1 programming-using-java -introduction
1 programming-using-java -introduction1 programming-using-java -introduction
1 programming-using-java -introduction
Mahmoud Alfarra
 
تلخيص النصوص تلقائيا
تلخيص النصوص تلقائياتلخيص النصوص تلقائيا
تلخيص النصوص تلقائيا
Mahmoud Alfarra
 
4×4×4 لتحصيل التميز
4×4×4 لتحصيل التميز4×4×4 لتحصيل التميز
4×4×4 لتحصيل التميز
Mahmoud Alfarra
 
Data preparation and processing chapter 2
Data preparation and processing chapter  2Data preparation and processing chapter  2
Data preparation and processing chapter 2
Mahmoud Alfarra
 
Introduction to-data-mining chapter 1
Introduction to-data-mining  chapter 1Introduction to-data-mining  chapter 1
Introduction to-data-mining chapter 1
Mahmoud Alfarra
 
Computer Programming, Loops using Java - part 2
Computer Programming, Loops using Java - part 2Computer Programming, Loops using Java - part 2
Computer Programming, Loops using Java - part 2
Mahmoud Alfarra
 
Computer Programming, Loops using Java
Computer Programming, Loops using JavaComputer Programming, Loops using Java
Computer Programming, Loops using Java
Mahmoud Alfarra
 
Chapter 10: hashing data structure
Chapter 10:  hashing data structureChapter 10:  hashing data structure
Chapter 10: hashing data structure
Mahmoud Alfarra
 
Chapter9 graph data structure
Chapter9  graph data structureChapter9  graph data structure
Chapter9 graph data structure
Mahmoud Alfarra
 
Chapter 8: tree data structure
Chapter 8:  tree data structureChapter 8:  tree data structure
Chapter 8: tree data structure
Mahmoud Alfarra
 
Chapter 2: array and array list data structure
Chapter 2: array and array list  data structureChapter 2: array and array list  data structure
Chapter 2: array and array list data structure
Mahmoud Alfarra
 
Chapter 0: introduction to data structure
Chapter 0: introduction to data structureChapter 0: introduction to data structure
Chapter 0: introduction to data structure
Mahmoud Alfarra
 
8 programming-using-java decision-making practices 20102011
8 programming-using-java decision-making practices 201020118 programming-using-java decision-making practices 20102011
8 programming-using-java decision-making practices 20102011
Mahmoud Alfarra
 
7 programming-using-java decision-making220102011
7 programming-using-java decision-making2201020117 programming-using-java decision-making220102011
7 programming-using-java decision-making220102011
Mahmoud Alfarra
 
6 programming-using-java decision-making20102011-
6 programming-using-java decision-making20102011-6 programming-using-java decision-making20102011-
6 programming-using-java decision-making20102011-
Mahmoud Alfarra
 
5 programming-using-java intro-tooop20102011
5 programming-using-java intro-tooop201020115 programming-using-java intro-tooop20102011
5 programming-using-java intro-tooop20102011
Mahmoud Alfarra
 
4 programming-using-java intro-tojava20102011
4 programming-using-java intro-tojava201020114 programming-using-java intro-tojava20102011
4 programming-using-java intro-tojava20102011
Mahmoud Alfarra
 
3 programming-using-java introduction-to computer
3 programming-using-java introduction-to computer3 programming-using-java introduction-to computer
3 programming-using-java introduction-to computer
Mahmoud Alfarra
 
2 programming-using-java how to built application
2 programming-using-java how to built application2 programming-using-java how to built application
2 programming-using-java how to built application
Mahmoud Alfarra
 
1 programming-using-java -introduction
1 programming-using-java -introduction1 programming-using-java -introduction
1 programming-using-java -introduction
Mahmoud Alfarra
 
تلخيص النصوص تلقائيا
تلخيص النصوص تلقائياتلخيص النصوص تلقائيا
تلخيص النصوص تلقائيا
Mahmoud Alfarra
 
4×4×4 لتحصيل التميز
4×4×4 لتحصيل التميز4×4×4 لتحصيل التميز
4×4×4 لتحصيل التميز
Mahmoud Alfarra
 
Data preparation and processing chapter 2
Data preparation and processing chapter  2Data preparation and processing chapter  2
Data preparation and processing chapter 2
Mahmoud Alfarra
 
Introduction to-data-mining chapter 1
Introduction to-data-mining  chapter 1Introduction to-data-mining  chapter 1
Introduction to-data-mining chapter 1
Mahmoud Alfarra
 
Ad

Recently uploaded (20)

LDMMIA About me 2025 Edition 3 College Volume
LDMMIA About me 2025 Edition 3 College VolumeLDMMIA About me 2025 Edition 3 College Volume
LDMMIA About me 2025 Edition 3 College Volume
LDM & Mia eStudios
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGYHUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
DHARMENDRA SAHU
 
PHYSIOLOGY & SPORTS INJURY by Diwakar Sir
PHYSIOLOGY & SPORTS INJURY by Diwakar SirPHYSIOLOGY & SPORTS INJURY by Diwakar Sir
PHYSIOLOGY & SPORTS INJURY by Diwakar Sir
Diwakar Kashyap
 
Introduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdfIntroduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdf
CME4Life
 
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdfTechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup
 
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdfপ্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
Pragya - UEM Kolkata Quiz Club
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
POS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 SlidesPOS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 Slides
Celine George
 
Multicultural approach in education - B.Ed
Multicultural approach in education - B.EdMulticultural approach in education - B.Ed
Multicultural approach in education - B.Ed
prathimagowda443
 
Dashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo SlidesDashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo Slides
Celine George
 
How to Setup Lunch in Odoo 18 - Odoo guides
How to Setup Lunch in Odoo 18 - Odoo guidesHow to Setup Lunch in Odoo 18 - Odoo guides
How to Setup Lunch in Odoo 18 - Odoo guides
Celine George
 
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptxQUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
Sourav Kr Podder
 
"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx
Arshad Shaikh
 
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
wygalkelceqg
 
How to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 WebsiteHow to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 Website
Celine George
 
Swachata Quiz - Prelims - 01.10.24 - Quiz Club IIT Patna
Swachata Quiz - Prelims - 01.10.24 - Quiz Club IIT PatnaSwachata Quiz - Prelims - 01.10.24 - Quiz Club IIT Patna
Swachata Quiz - Prelims - 01.10.24 - Quiz Club IIT Patna
Quiz Club, Indian Institute of Technology, Patna
 
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
Sritoma Majumder
 
Uterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managmentUterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managment
Ritu480198
 
Exploring Identity Through Colombian Companies
Exploring Identity Through Colombian CompaniesExploring Identity Through Colombian Companies
Exploring Identity Through Colombian Companies
OlgaLeonorTorresSnch
 
LDMMIA About me 2025 Edition 3 College Volume
LDMMIA About me 2025 Edition 3 College VolumeLDMMIA About me 2025 Edition 3 College Volume
LDMMIA About me 2025 Edition 3 College Volume
LDM & Mia eStudios
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGYHUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
DHARMENDRA SAHU
 
PHYSIOLOGY & SPORTS INJURY by Diwakar Sir
PHYSIOLOGY & SPORTS INJURY by Diwakar SirPHYSIOLOGY & SPORTS INJURY by Diwakar Sir
PHYSIOLOGY & SPORTS INJURY by Diwakar Sir
Diwakar Kashyap
 
Introduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdfIntroduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdf
CME4Life
 
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdfTechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup
 
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdfপ্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
Pragya - UEM Kolkata Quiz Club
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
POS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 SlidesPOS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 Slides
Celine George
 
Multicultural approach in education - B.Ed
Multicultural approach in education - B.EdMulticultural approach in education - B.Ed
Multicultural approach in education - B.Ed
prathimagowda443
 
Dashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo SlidesDashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo Slides
Celine George
 
How to Setup Lunch in Odoo 18 - Odoo guides
How to Setup Lunch in Odoo 18 - Odoo guidesHow to Setup Lunch in Odoo 18 - Odoo guides
How to Setup Lunch in Odoo 18 - Odoo guides
Celine George
 
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptxQUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
Sourav Kr Podder
 
"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx
Arshad Shaikh
 
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
wygalkelceqg
 
How to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 WebsiteHow to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 Website
Celine George
 
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
Sritoma Majumder
 
Uterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managmentUterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managment
Ritu480198
 
Exploring Identity Through Colombian Companies
Exploring Identity Through Colombian CompaniesExploring Identity Through Colombian Companies
Exploring Identity Through Colombian Companies
OlgaLeonorTorresSnch
 

Chapter 7: Queue data structure

  • 1. DATA STRUCTURE Chapter 7: Queue Prepared & Presented by Mr. Mahmoud R. Alfarra 2011-2012 College of Science & Technology Dep. Of Computer Science & IT BCs of Information Technology http://mfarra.cst.ps
  • 2. Out Line  What is Queue data structure?  EnQueue operation  DeQueue operation  Clear the Queue  Print all data of Queue  Search about data  Queue Class  Types of Queue 2
  • 3. What is Queue data structure?  Queues are used to prioritize operating system processes and to simulate events in the real world, such as teller lines at banks and the operation of elevators in buildings.  A queue is a data structure where data enters at the rear of a list and is removed from the front of the list.  Queues are an example of a first-in, first-out (FIFO) data structure. 3 Mohame d Ghadeer Ali Ahmed Hussam Rear Front
  • 4. Queue Operations  The two primary operations involving queues are adding a new item to the queue and removing an item from the queue.  The operation for adding a new item is called Enqueue, and the operation for removing an item from a queue is called Dequeue.  The other primary operation (The Peek method) to perform on a queue is viewing the beginning  item. 4
  • 5. What is Queue data structure? 5
  • 6. Element of Queue 6 ‫البيانات‬ ‫تراكيب‬ ‫مساق‬ ‫إعداد‬ ‫العلمية‬ ‫المادة‬ / ‫أ‬ . ‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬  Exactly as linked list and stack …
  • 7. 1- Element of Queue (customer) 7 ‫البيانات‬ ‫تراكيب‬ ‫مساق‬ ‫إعداد‬ ‫العلمية‬ ‫المادة‬ / ‫أ‬ . ‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬ 1. class Customer { 2. public int parts; 3. public int amount; 4. public String name; 5. public Customer next; 6. public Customer() { 7. parts = 0; 8. amount = 0; 9. name = "no name"; } 10. public Customer(int parts, int amount, String name) { 11. this.parts = parts; 12. this.amount = amount; 13. this.name = name; } }
  • 8. 2- Class Queue of customer 8 ‫البيانات‬ ‫تراكيب‬ ‫مساق‬ ‫إعداد‬ ‫العلمية‬ ‫المادة‬ / ‫أ‬ . ‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬ 1. class QueueOfCustomer { 2. public Customer Front; 3. public Customer Rear; 4. public int length; 5. public QueueOfCustomer() 6. { 7. Front = null; 8. Rear = null; 9. length = 0; 10. } 11.}
  • 10. EnQueue Operation 10 1. public void InQueue(Customer addCus) 2. { 3. Customer newc = addCus; 4. if (Front == null) 5. { 6. Front = newc; 7. Rear = newc; 8. newc.next = null; 9. } 10. else 11. { 12. newc.next = Rear; 13. Rear = newc; 14. } 15. length++; 16. Console.WriteLine("The new Object is added: "+length); 17. }
  • 12. DeQueue operation 12 1. public void DeQueue() { 2. if (Front == null) 3. Console.WriteLine("The Queue is Empty!!"); 4. else 5. { 6. Customer current; 7. Customer pre_current = Rear; 8. for (current = Rear; current.next != null; current = current.next) 9. pre_current = current; 10. Front = pre_current; 11. length--;} }
  • 14. Peek Operation 14 ‫البيانات‬ ‫تراكيب‬ ‫مساق‬ ‫إعداد‬ ‫العلمية‬ ‫المادة‬ / ‫أ‬ . ‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬ 1. public void Peek() 2. { 3. if (Front == null) 4. Console.WriteLine("The Queue is empty"); 5. else 6. Console.WriteLine("The Data of the first is:n "+ 7. Front.name +"n "+Front.amount+"n "+Front.parts); 8. }
  • 15. Clear the Queue 15 1. public void Clear() 2. { 3. if (Rear == null) 4. Console.WriteLine("The Queue is Empty!!"); 5. else 6. Rear = null; 7. Length = 0; 8. }
  • 16. Print all data of Queue 16 Mohame d Ghadeer Ali Rear Front Ahmed current current current current
  • 17. Print all data of Queue 17 ‫البيانات‬ ‫تراكيب‬ ‫مساق‬ ‫إعداد‬ ‫العلمية‬ ‫المادة‬ / ‫أ‬ . ‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬ 1. public void PrintAll() 2. { 3. Customer current; 4. for (current = Rear; current != null; current = current.next) 5. { 6. Console.WriteLine(" ========================== "); 7. Console.WriteLine("The Data of the element is:n " + 8. current.name + "n " + current.amount + "n " + current.parts); 9. Console.WriteLine(" ========================== "); 10. } 11. }
  • 18. Search about data 18 Mohame d Ghadeer Ali Rear Front Ahmed current current current current
  • 19. Search about data 19 ‫البيانات‬ ‫تراكيب‬ ‫مساق‬ ‫إعداد‬ ‫العلمية‬ ‫المادة‬ / ‫أ‬ . ‫ا‬ َّ‫الفــر‬ ‫رفيق‬ ‫محمود‬ 1. public void SearchByAmount(int amount) 2. { 3. Customer current = Rear; 4. bool flag = false; 5. while (current != null) 6. { 7. if (current.amount == amount) 8. { 9. flag = true; 10. break; 11. } 12. current = current.next; 13. } 14. if (flag == true) 15. Console.WriteLine("The element is exist!! "); 16. else 17. Console.WriteLine("The element does not exist!! "); 18. }
  • 20. Queue Class  Class of Queue available in collection space of .Net. 20 Practice : develop a full application using class of Queue
  • 21. Types of Queue  Linear queue  Circular queue  Double ended queue
  • 22. Thank You … 22 Remember that: question is the key of knowledge
  • 23. Ahl Eljanna   َ ‫ه‬َ‫ن‬َ ‫و‬ ٍ ‫َّات‬‫ن‬َ ‫ج‬ ِ ‫ِف‬ َ ‫ني‬ِ ‫َّق‬‫ت‬ُ ‫ْم‬‫ل‬‫ا‬ َّ ‫ن‬ِ‫إ‬ ٍ ‫ر‬ )::( ِ ‫ع‬ ٍ ‫ق‬ْ ‫د‬ِ ‫ص‬ ِ ‫د‬َ ‫ع‬ْ ‫ق‬َ ‫م‬ ِ ‫ِف‬ َ ‫د‬ْ‫ن‬ ٍ ‫ر‬ِ ‫د‬َ‫ت‬ْ ‫ق‬ُ ‫م‬ ٍ ‫يك‬ِ‫ل‬َ ‫م‬ )::( 23