Queue | The Data Structure which Schedules the Disk

Photo by Levi Jones on Unsplash

When I was a child, I always wondered how Memory writes the data? Learning about process scheduling and memory management techniques in OS I understood that all this works properly because of Queue Data Structure. Our memory can write a binary code or I say data because of managed working of processes and resources. Not only in memory management but CPU, RAM, Processor, and even Companies use the data structure Queue to manage the work properly.

Photo by Alex Kotliarskyi on Unsplash

Queue is a Data Structure that works on the FIFO principle. (FIFO — First In First Out). The queue is similar to that of the queue in the ticket line. The person who joined the queue will get the ticket first and the person who joined the queue last will get the ticket at the end.

(Question of the Article: Queue works on FIFO, Stack Works on ______.

Click here to Check the Answer)


First In First Out means the first comer will be served first. Like a Hotel.

Let’s learn these technical words which are used in Data Structures.

  1. Empty Queue: the Queue with zero elements
  2. Enqueue: Adding Element in the Queue
  3. Dequeue: Removing Element from the Queue
  4. IsEmpty: Checks whether the Queue is Empty or Not
  5. IsFull: Checks whether the Queue is Full or Not
  6. Peek: Value of the Front or First Element of the Queue
Photo by Андрей Сизов on Unsplash


  1. Initialise two variables Front and Rear
  2. Front track the first element of the Queue
  3. Rear tracks the last element of the Queue
  4. Initialise, the Front and Rear equal to -1


  • check whether the Queue is Full or Not
  • update front = 0 and rear = 1
  • add the element to the queue


  • check whether the queue is empty or not
  • check the value of front
  • increase front by One

(Question of the Article: What do we use to check the Value of the Front Element?

Answer is in FIFO ☝ )

Photo by Markus Spiske on Unsplash



Applications of Queue

  • CPU Scheduling
  • Disk Scheduling
  • Handling of Interrupts in Real-time
  • Call center phone call management
  • Process Management
  • Handling website traffic
  • Routers



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store