UMBC CS 201, Fall 05
A queue is what Americans commonly refer to as a line. The
example is that you get into a line at the grocery store. In Great Britain,
lines, like the line of customers waiting at the checkout, are called queues.
The word queue is more specific. The word line can also mean, a line between
two points, the line down the middle of the road, etc.
People have been exposed to the idea of getting in line, or "queueing up",
as the Brits say, since their mothers took them to the bank or the grocery
store in their strollers. So we all know the rules of a queue.
A queue is a linear collection, where something to be added to the queue must
be placed at the end of the queue. Items are removed from the queue from the
front. To keep with the analogy, when you walk into the bank you go to the
end of the queue. When the teller is ready to help the next person, the
person at the beginning of the queue is removed from the queue. Each person
then moves one position closer to the beginning of the queue. Eventually,
you will be the first person in the queue and the teller will call you up
causing you to be removed from the queue.
A queue is refered to as a FIFO data structure: First In, First Out.
The Queue ADT
A queue is a linear collection of items, where an item to be added to
the queue must be placed at the end of the queue and items that are removed
from the queue must be removed from the front. The end of the queue is known
as the tail and the front of the queue is known as the head.
The term enqueue means to add an item to the queue, and the term
dequeue means to remove an item from the queue.
There are actually very few operations on a queue.
- Enqueue - add an item to the queue
- Dequeue - remove an item from the queue
- IsEmpty - is this an empty queue ?
- PrintQueue - print the contents of the queue
Thursday, 29-Sep-2005 00:00:27 EDT