FANDOM


A queue is a first-in-first-out list data structure. That is, the first item inserted in the list would be the first item to be retrieved in the list. The "inverse" of a queue is a stack.

This structure inherits both its name and its logic from a waiting line of people, as at a bank or restaurant. Such lines are based on the principle of "first come, first served"; queues are "first in, first out," or FIFO.

Common operations are:

  • enqueue - adds an item in the queue.
  • dequeue - "gets" the next item in the queue, that is, it retrieves the next item in the queue and removes it.

Less common operations are:

  • count - number of items. Rather easy to add in an implementation.
  • peek - retrieves the next item in the queue without removing it.

Common implementationsEdit

  • using of a single linked list or a double linked list
  • using of two or three Stacks

See alsoEdit

External linksEdit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.