SlideShare a Scribd company logo
1 of 14
By
Muskan. S
(Embedded System and VLSI)
QUEUE
2
Queue
⚫ A queue is an ordered collection of items where an item is
inserted at one end called the “rear” and an existing item is
removed at the other end, called the “front”.
⚫ Queue is also called as FIFO list i.e. First-In First- Out.
⚫ In the queue only two operations are allowed enqueue and
dequeue.
⚫ Enqueue means to insert an item into back of the queue.
⚫ Dequeue means removing the front item.The people standing
in a railway reservation row are an example of queue.
48
Prof. K. Adisesha
3
Queue
⚫The queue can be implemented into two ways:
◦ Using arrays (Static implementation)
◦ Using pointer (Dynamic implementation)
49
Prof. K. Adisesha
4
T
ypes of Queues
⚫Queue can be of four types:
o Simple Queue
o Circular Queue
o Priority Queue
o De-queue ( Double Ended Queue)
5
Simple Queue
⚫Simple Queue: In simple queue insertion occurs at the
rear end of the list and deletion occurs at the front end
of the list.
6
Circular Queue
⚫Circular Queue:Acircular queue is a queue in which all
nodes are treated as circular such that the last node
follows the first node.
7
Priority Queue
⚫A priority queue is a queue that contains items that have some
present priority. An element can be inserted or removed from
any position depending upon some priority.
8
Dequeue Queue
⚫Dequeue: It is a queue in which insertion and
deletion takes place at the both ends.
9
Operation on Queues
⚫Queue( ): It creates a new queue that is empty.
⚫enqueue(item): It adds a new item to the rear of the queue.
⚫dequeue( ): It removes the front item from the queue.
⚫isEmpty( ): It tests to see whether the queue is empty.
⚫size( ): It returns the number of items in the queue.
10
Memory Representation of a queue using array
⚫ Queue is represented in memory using linear array.
⚫ Let QUEUE is a array, two pointer variables called FRONT and
REAR are maintained.
⚫ The pointer variable FRONT contains the location of the element to be removed or
deleted.
⚫ The pointer variable REAR contains location of the last
element inserted.
⚫ The condition FRONT = NULL indicates that queue is
empty.
⚫ The condition REAR = N-1 indicates that queue is full.
11
Queue Insertion Operation (ENQUEUE):
⚫ ALGORITHM: ENQUEUE (QUEUE, REAR, FRONT, ITEM)
QUEUE is the array with N elements. FRONT is the pointer that contains the location of the
element to be deleted and REAR contains the location of the inserted element. ITEM is the
element to be inserted.
Step 1: if REAR = N-1 then [Check Overflow] PRINT
“QUEUE is Full or Overflow”
Exit [End if]
Step 2: if FRONT = NULL then [Check Whether Queue is empty] FRONT = -1
REAR = -1
else
REAR = REAR + 1 [Increment REAR Pointer]
Step 3: QUEUE[REAR] = ITEM [Copy ITEM to REAR position]
Step 4: Return
12
Queue Deletion Operation (DEQUEUE)
ALGORITHM: DEQUEUE (QUEUE, REAR, FRONT, ITEM)
QUEUE is the array with N elements. FRONT is the pointer that contains the location of the
element to be deleted and REAR contains the location of the inserted element. ITEM is the
element to be inserted.
Step 1: if FRONT = NULL then [Check Whether Queue is empty] PRINT “QUEUE is
Empty or Underflow”
Exit [End if]
Step 2: ITEM = QUEUE[FRONT]
Step 3: if FRONT = REAR then [if QUEUE has only one element] FRONT = NULL
REAR = NULL
else
FRONT = FRONT + 1 [Increment FRONT pointer]
Step 4: Return
13
Application of Queue
⚫Simulation
⚫Various features of Operating system
⚫Multi-programming platform systems.
⚫Different types of scheduling algorithms
⚫Round robin technique algorithms
⚫Printer server routines
⚫Various application software’s is also based on
queue data structure.
THANK YOU

More Related Content

Similar to Queue data structures and operation on data structures

Similar to Queue data structures and operation on data structures (20)

23 stacks-queues-deques
23 stacks-queues-deques23 stacks-queues-deques
23 stacks-queues-deques
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
 
QUEUE.pptx
QUEUE.pptxQUEUE.pptx
QUEUE.pptx
 
2.1 Queue.pptx
2.1 Queue.pptx2.1 Queue.pptx
2.1 Queue.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
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
Queue and its operations
Queue and its operationsQueue and its operations
Queue and its operations
 
Queue
QueueQueue
Queue
 
Stack & Queue
Stack & QueueStack & Queue
Stack & Queue
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Stack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparationStack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparation
 
Data Structure Lecture 4
Data Structure Lecture 4Data Structure Lecture 4
Data Structure Lecture 4
 
Queue - Operations and Implementations
Queue - Operations and ImplementationsQueue - Operations and Implementations
Queue - Operations and Implementations
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
Queue
QueueQueue
Queue
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Queues in C++
Queues in C++Queues in C++
Queues in C++
 
4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data Structure
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
 
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)
 

Recently uploaded

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Recently uploaded (20)

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

Queue data structures and operation on data structures

  • 2. 2 Queue ⚫ A queue is an ordered collection of items where an item is inserted at one end called the “rear” and an existing item is removed at the other end, called the “front”. ⚫ Queue is also called as FIFO list i.e. First-In First- Out. ⚫ In the queue only two operations are allowed enqueue and dequeue. ⚫ Enqueue means to insert an item into back of the queue. ⚫ Dequeue means removing the front item.The people standing in a railway reservation row are an example of queue. 48 Prof. K. Adisesha
  • 3. 3 Queue ⚫The queue can be implemented into two ways: ◦ Using arrays (Static implementation) ◦ Using pointer (Dynamic implementation) 49 Prof. K. Adisesha
  • 4. 4 T ypes of Queues ⚫Queue can be of four types: o Simple Queue o Circular Queue o Priority Queue o De-queue ( Double Ended Queue)
  • 5. 5 Simple Queue ⚫Simple Queue: In simple queue insertion occurs at the rear end of the list and deletion occurs at the front end of the list.
  • 6. 6 Circular Queue ⚫Circular Queue:Acircular queue is a queue in which all nodes are treated as circular such that the last node follows the first node.
  • 7. 7 Priority Queue ⚫A priority queue is a queue that contains items that have some present priority. An element can be inserted or removed from any position depending upon some priority.
  • 8. 8 Dequeue Queue ⚫Dequeue: It is a queue in which insertion and deletion takes place at the both ends.
  • 9. 9 Operation on Queues ⚫Queue( ): It creates a new queue that is empty. ⚫enqueue(item): It adds a new item to the rear of the queue. ⚫dequeue( ): It removes the front item from the queue. ⚫isEmpty( ): It tests to see whether the queue is empty. ⚫size( ): It returns the number of items in the queue.
  • 10. 10 Memory Representation of a queue using array ⚫ Queue is represented in memory using linear array. ⚫ Let QUEUE is a array, two pointer variables called FRONT and REAR are maintained. ⚫ The pointer variable FRONT contains the location of the element to be removed or deleted. ⚫ The pointer variable REAR contains location of the last element inserted. ⚫ The condition FRONT = NULL indicates that queue is empty. ⚫ The condition REAR = N-1 indicates that queue is full.
  • 11. 11 Queue Insertion Operation (ENQUEUE): ⚫ ALGORITHM: ENQUEUE (QUEUE, REAR, FRONT, ITEM) QUEUE is the array with N elements. FRONT is the pointer that contains the location of the element to be deleted and REAR contains the location of the inserted element. ITEM is the element to be inserted. Step 1: if REAR = N-1 then [Check Overflow] PRINT “QUEUE is Full or Overflow” Exit [End if] Step 2: if FRONT = NULL then [Check Whether Queue is empty] FRONT = -1 REAR = -1 else REAR = REAR + 1 [Increment REAR Pointer] Step 3: QUEUE[REAR] = ITEM [Copy ITEM to REAR position] Step 4: Return
  • 12. 12 Queue Deletion Operation (DEQUEUE) ALGORITHM: DEQUEUE (QUEUE, REAR, FRONT, ITEM) QUEUE is the array with N elements. FRONT is the pointer that contains the location of the element to be deleted and REAR contains the location of the inserted element. ITEM is the element to be inserted. Step 1: if FRONT = NULL then [Check Whether Queue is empty] PRINT “QUEUE is Empty or Underflow” Exit [End if] Step 2: ITEM = QUEUE[FRONT] Step 3: if FRONT = REAR then [if QUEUE has only one element] FRONT = NULL REAR = NULL else FRONT = FRONT + 1 [Increment FRONT pointer] Step 4: Return
  • 13. 13 Application of Queue ⚫Simulation ⚫Various features of Operating system ⚫Multi-programming platform systems. ⚫Different types of scheduling algorithms ⚫Round robin technique algorithms ⚫Printer server routines ⚫Various application software’s is also based on queue data structure.