Algorithms and Data Structures Wiki
Advertisement

A Queue is an Abstract Data Type (ADT) similar to a stack. In contrast to a stack, it is open as both ends. One end is used to insert data (enqueue) and the other end is used to delete data (dequeue).

A Queue to store and retrieve values in a "First-In, First-Out"(FIFO) fashion, i.e. the item which is stored first will be accesses first.

Queues are used when we need to access data items in their exact sequence of arrival. Every operating system maintains queues of various processes. Priority Queues and Breath First traversal of Graphs are some examples of Queues.

Stack Operations[]

The following operations can be performed on a stack:

  • enqueue() - add an item to the rear of the queue
  • dequeue() - remove an item from the front of the queue
  • peek() - look up the value of the front item without removing it
  • isEmpty() - checks if the queue is empty
  • isFull() - checks if the queue is full
Advertisement