Professional Documents
Culture Documents
Chapt 08
Chapt 08
Data Structures
and Other Objects
Using C++
Front
Rear
Front
Rear
Front
Rear
Array Implementation
[0]
[1]
[2]
An array of integers
to implement a
queue of integers
[3]
[4]
[5]
...
Array Implementation
[1]
[2]
[3]
[4]
[5]
...
size
first
last
A Dequeue Operation
[0]
[1]
[2]
[3]
[4]
[5]
...
size
first
last
An Enqueue Operation
[0]
[1]
[2]
[3]
[4]
[5]
...
size
first
last
[0]
[1]
[2]
[3]
[4]
[5]
size
first
last
[0]
4
[1]
[2]
[3]
[4]
[5]
size
first
last
Array Implementation
Easy to implement
But it has a limited capacity with a fixed array
Or you must use a dynamic array for an
unbounded capacity
Special behavior is needed when the rear reaches
the end of the array.
[0]
[1]
[2]
[3]
[4]
[5]
...
size
first
last
13
15
10
7
null
head_ptr
tail_ptr
13
Front
15
10
7
null
head_ptr
tail_ptr
Rear
Summary
Like
THE END