Title: QUEUES
1QUEUES
Sarah Swiss
2Queue is a linear list in which data can only be
inserted at one end, called the rear, and deleted
from the other end called the front. These
restrictions ensure that the data are processed
through the queues in the order in which they are
received. A queue is the same as a line.
3Examples of Queues
Insert (enqueue)
a. A queues (line) of people
Remove (dequeue)
b. A computer queue
4Although there are many operations for queue,
three are basic ENQUEUE DEQUEUE EMPTY
5The queue insert operation in know as enqueue
Queue
plum
kiwi
Enqueue
Operation
grape
ENQUEUE
plum
grape
front
kiwi
Queue
After the data has been inserted into the queue,
the new element becomes the rear. The only
potential problem with enqueue is running out of
room for the data. If there is not enough room
for another element in the queue, the queue is in
overflow state
6The queue delete operation is know as dequeue
Queue
front
plum
kiwi
grape
Operation
Dequeue
DEQUEUE
front
kiwi
grape
Queue
The data at the front of the queue are removed
from the removed the queue and returned to the
user. If there is no data in the queue when
dequeue is attempted, the queue is in an
underflow state.
7This operation check to see if a queue is empty
or not. The result is true or false.
Example 2
Show the result of the following operation on a
queue Q
enqueue (Q,23) If not empty (Q), dequeue
(Q) enqueue (Q,20) Enqueue (Q,19) If not empty
(Q), dequeue (Q)
EMPTY
Solution
front
front
23
front
Q
Q
Q
front
front
front
20
20
19
19
Q
Q
Q
8A queue can be implemented as either an array or
a linked list Queues are one of the most common
of all data processing structures. They are found
in virtually every operating system and network
and in countless other areas. They are used in
business online applications such as processing
customer requests, jobs, and orders. In a
computer system, a queue is needed to process
jobs and for system services such as print
spools.