Overview of Queue

A stack is a data structure which stores elements one after others. 

A unique feature of this data structure is that we can use an array or linked list for its implementation. We are concerned about its functionality instead of it is implemented in code. Thus, the queue is an abstract data type. 

Consider a group of students waiting outside the professor's cabin in line for project submission. 



The queue increases when more people arrive. 

The queue decreases when professor calls the student and he/she goes inside the cabin. Note that other students do not shift to fill vacant space.


Thus people are served from First Come First Serve basis. This approach is known as First In First Out procedure. The process of addition of elements is called enqueue, and the process of deletion of elements is called dequeue.


We can deduce an analogy that people are equivalent to data elements. 

We use two variables for performing operations. 

  1. Rear/Back- Denotes the end for enqueueing.
  2. Front- Denotes the end for dequeuing.

There are two states which can be determined by the value of "front" pointer.

  1. Overflow- It means that the queue is full.
  2. Underflow- It means that the queue is empty.
                                   I

                                                                                                                                                 Image credits: Wikimedia Commons


Advantages of this data structure are:

  1. Easy insertion and deletion of elements.

Disadvantages of this data structure are:

  1. Elements cannot be randomly accessed.
  2. Upon deletion, the cleared memory space is not available for reuse. However, the circular queue overcomes this limitation.

Note: Advantages and disadvantages of data structure used for the implementation of the queue are reflected.


Applications of this data structure are:

  1. Used for the breadth-first-search algorithm.
  2. Can be used for interprocess communication.
  3. Interrupt handling by CPU.

Comments

Popular posts from this blog

Overview of Tree Data Structure

Overview of Three Dimensional Array

Overview of Priority Queue