Queue is a collection whose elements are added at one end and removed from the other end
What is a Queue
Conceptual View of a Queue
Uses of Queues in Computing
Operations on a Queue
Implementation of a Queue
Applications
Downloadable Resources
5. 4
Queue
• Queue: a collection whose elements are
added at one end (the rear or tail of the
queue) and removed from the other end
(the front or head of the queue)
• A queue is a FIFO (first in, first out) data
structure
• Any waiting line is a queue:
–The check-out line at a grocery store
–The cars at a stop light
–An assembly line
7. Conceptual View of a Queue
Front of queue
Adding an element
The new element is
added to the rear of the
queue
5
8. Removing an element
New front element of queue
The element is removed
from the front of the
queue
Conceptual View of a Queue
6
9. 9
Uses of Queues in Computing
• Printer queue
• Keyboard input buffer
• GUI event queue (click on buttons, menu items)
• To encode messages
• For any kind of problem involving FIFO data
10. 10
Operations on a Queue
Operation Description
remove Removes an element from the front of the queue
insert Adds an element to the rear of the queue
isFull Determines whether the queue is full
isEmpty Determines whether the queue is empty
16. Summary
• Queue: a collection whose elements are
added at one end and removed from the
other end
• A queue is a FIFO (first in, first out) data
structure
• Queue Implementation (Java)
16
17. Questions
1. Specify 3 usages of Queues in Computing.
2. Identify which of the following is/are true? In
each case justify your answer.
a. Web browsers use queues to retrieve data
b. In the front fix array bases queue
implementation, remove operation is less
efficient than insert
17