AlgoDocs

Queue

A queue is a linear data structure that follows the FIFO principle

A queue is a simple, linear data structure that follows the First In, First Out (FIFO) principle. This means that the first element added to the queue will be the first one to be removed.

Key Concept

  • FIFO Principle (First In, First Out): The first element added to the queue will be the first one to be removed.

  • Example: Think of a line at a ticket counter. When a person joins the line, they stand at the back. To be served, the person at the front of the line is attended to first, and others move forward in order.

Visualization of First In First Out

Key Terms in Queue

  1. Enqueue:

    The operation of adding an element to the end (rear) of the queue.

  2. Dequeue:

    The operation of removing an element from the front of the queue.

  3. Front:

    The first element in the queue, which is the next to be dequeued.

  4. Rear (or Back):

    The last element in the queue, where new elements are added.

Visualization of Representation of Queue

How is this guide?