A Simple Introduction to Queue Data Structure

Hamid AK
2 min readAug 10, 2020

--

Queue data structure

In this article you will learn about queue data structure, what is a queue, what it’s application and how you can implement it.

Table of Contents:

  • what is queue data structure?
  • operations of queue data structure
  • applications of queue data structure
  • Implementation of queue data structure

What is queue data structure?

A queue is a linear data structure which follows the FIFO(first-in first-out).

Queue is also an abstract data type or a linear data structure, in which the first element is inserted from one end called the REAR(also called tail), and the removal of existing element takes place from the other end called as FRONT(also called head).

front and rear of queue

The operation of adding an element to the rear of the queue is known as enqueue, and the operation of removing an element from the front is known as dequeue.

adding:enqueue, removing:dequeue

Operations of queue data structure:

  • peek: returns the object at the front of the queue without removing it.
  • enqueue: inserts a new item to the queue.
  • dequeue: removes the object from the front of the queue, thereby decrementing queue size by one.
  • isEmpty: check if the queue is empty.
  • size: return the number of elements present in the queue.

Applications of queue data structure:

  • Handles multi-user, multi-programming environment, and time-sharing environment.
  • In real-world queue is used for customer service like railway reservation, etc.
  • serving requests on a single shared resource, like a printer, CPU task scheduling etc.
  • in real life scenario, Call Center phone systems uses Queues to hold people calling them in an order, until a service representative is free.
  • To implement the Round-robin scheduling technique.

Implementation of Queue Data Structure:

Queue can be implemented using an Array, Stack or Linked List. The easiest way of implementing a queue is by using an Array.

For more of these type of information, you can follow me on Twitter HamidAK

and on medium Hamid AK

--

--

Hamid AK
0 Followers

👨‍💻 20 Years Old #Coder 💼 3 Years of #Java ★ 3 years of #Android 📱️ ★ 1 year of #python Software Engineer 💻 Sudan 🇸🇩️