Queue

In this lesson, we'll study queues!

We'll cover the following

Queue

A queue is a linear data structure where a particular order in operations is maintained i.e., FIFO (First In First Out).

In Queue, we remove the least recently added element. In Stack, we remove the most recently added element.

We maintain front and back, meaning elements are inserted at the back and removed from the front.

The operations on Queue are:

  • Push: Insert an element at the end
  • Pop: Remove the first element
  • Front: Get the front element
  • Back: Get the last element

Optionally you have isEmpty and size functions.

All operations take O(1)O(1) time.

Visualize

Get hands-on with 1200+ tech skills courses.