Lecture 4-Queues 071655
Lecture 4-Queues 071655
LINEAR LISTS
(Queues)
Front of queue
New element is
added to the rear of
the queue
Element is removed
from the front of the
queue
ICT 224– DATA STRUCTURES AND ALGORITHMS, By 7
Matthew Cobbinah
Queues in computer science
Operating systems:
Waiting lists for a single shared resource like printer,
disk, CPU.
Queue of programs / processes to be run
Queue of network data packets to send
In operating systems for handling interrupts.
Keyboard input buffer
(as buffers also in MP3 media player, CD player)
Programming:
Modeling a line of customers or clients
Storing a queue of computations to be performed in
order
GUI event queue (click on buttons, menu items)
1. Simple or Linear or
ordinary
2. Circular
3. Priority
4. Double Ended (Deque)
rear
q
front
4
count
rear
q
front
5
count
rear
q
front
4
count
front
0 1 2 3 4
…
queue
aq
4
count
0 1 2 3 4
…
queue
aq
5
count
0 1 2 3 4
…
queue
aq
4
count
front
12 12
11 11
rear rear
10 10
rear
1
0
front
12
11
After 8 more enqueues
10
35
ICT 224– DATA STRUCTURES AND ALGORITHMS,
Circular Array Implementation
When an element is enqueued, the value of rear is
incremented
But it must take into account the need to loop back to
index 0: