Understanding the Queue Data Structure and Its Implementations

Jake Zhang
7 min readAug 11, 2020

A queue is a collection of items whereby its operations work in a FIFO — First In First Out manner. The two primary operations associated with them are enqueue and dequeue.

This lesson was originally published at https://algodaily.com, where I maintain a technical interview course and write think-pieces for ambitious developers.

Lesson Objectives: At the end of this lesson, you will be able to:

  1. Know what the queue data structure is and appreciate it’s real-world use cases.
  2. Learn how queues work and their operations.
  3. Know and implement queues with two different approaches.

I’m sure all of us have been in queues before — perhaps at billing counters, shopping centers, or cafes. The first person in the line is usually serviced first, then the second, third, and so forth.

We have this concept in computer science as well. Take the example of a printer. Suppose we have a shared printer, and several jobs are to be printed at once. The printer maintains a printing “queue” internally, and prints the jobs in sequence based on which came first.

Another instance where queues are extensively used is in the operating system of our machines. An OS maintains several queues such…

--

--