what is queue in data structure

1 year ago 55
Nature

A queue is a linear data structure that is open at both ends and the operations are performed in First In First Out (FIFO) order. In a FIFO data structure, the first element added to the queue will be the first one to be removed. The position of the entry in a queue ready to be served is called the front of the queue, and the position of the last entry in the queue is called the rear (or the tail) of the queue. A queue can handle multiple data and can be accessed from both ends. The basic operations of a queue are:

  • Enqueue: Adds (or stores) an element to the end of the queue.
  • Dequeue: Removes an element from the front of the queue.
  • Peek (or front): Acquires the data element available at the front node of the queue without deleting it.
  • Rear: Returns the element at the rear end without removing it.
  • IsEmpty: Checks if the queue is empty.
  • IsFull: Validates if the queue is full.

Queues are commonly used in computer programs, where they are implemented as data structures coupled with access routines, as an abstract data structure, or in object-oriented languages as classes. Common implementations of queues are circular buffers and linked lists. Queues can also be implemented as a purely functional data structure.