NIST

queue

(data structure)

Definition: A collection of items in which only the earliest added item may be accessed. Basic operations are add (to the tail) or enqueue and delete (from the head) or dequeue. Delete returns the item removed. Also known as "first-in, first-out" or FIFO.

Formal Definition: It is convenient to define delete or dequeue in terms of remove and a new operation, front. The operations new(), add(v, Q), front(Q), and remove(Q) may be defined with axiomatic semantics as follows.

  1. new() returns a queue
  2. front(add(v, new())) = v
  3. remove(add(v, new())) = new()
  4. front(add(v, add(w, Q))) = front(add(w, Q))
  5. remove(add(v, add(w, Q))) = add(v, remove(add(w, Q)))
where Q is a queue and v and w are values.

Also known as FIFO.

Generalization (I am a kind of ...)
abstract data type.

Specialization (... is a kind of me.)
bounded queue.

See also deque, stack, priority queue, first come, first served.

Author: PEB

Implementation

(Java). Darius Bacon's functional implementation (Scheme).

More information

Demonstrations with dynamic array, fixed array, and linked list implementations.


Go to the Dictionary of Algorithms and Data Structures home page.

If you have suggestions, corrections, or comments, please get in touch with Paul E. Black  (paul.black@nist.gov).

Entry modified Tue Jan 4 09:47:54 2005.
HTML page formatted Tue Jan 4 10:21:57 2005.

This page's URL is http://www.nist.gov/dads/HTML/queue.html

to NIST home page