previous | index

A Linked-List Queue Representation

Enlarging the queue "on the fly" has the same drawbacks as for stacks: it takes time and might waste space.

We can use a linked node list as with stacks.

However, for efficiency we must be able to quickly access both the head and the tail positions:

Q: Which end of the list should be the head, and which the tail?

A: The head should be the start of the list (item 5), because dequeueing from the start is more efficient than from the end.

Implementing this queue representation is Exercise 13.13.


previous | index