# QUEUE: What is a queue in a data structure?

I am going to discuss the queue in this blog post(What is a queue in a data structure). A queue is also known as a non-primitive linear data structure. In this queue, the element is grouped in order.

Inside this blog post(What is a queue in a data structure), we are going to share the What is a queue in data structures? What are the queue in the data structure and their types? What is the queue explain? What is a queue example?

### What is a queue in data structures?

The queue is known as an abstract data structure and is quite similar to a stack. But unlike the stack queue is open at both ends and records are inserted from one end and removed from another end.

### What are the queue in the data structure and their types?

The queue is a FIFO(First in and first out) data structure where the element first added would be deleted first. The element in the queue is added sequentially hence it is also called a linear data structure.

The two main operations of the queue are insertion and deletion.

### What is a queue example?

There could be several examples of queue data structure. But here we can understand the queue with the help of a very simple example. A student queues in a library window.

First, the coming student will get books at first and last be served at last. the first student inserted in the row will be removed first as soon as he. or she gets all the books.

Here in the queue, the element is added at one end which is called the rear end, and the existing elements are removed from another end which is called the front end.

In the below Fig1, you can see a queue containing three elements A, B, and C. A is placed at the front of the queue and C is placed at the rear end.

In Fig2 an element has been deleted from the queue and since the element can be deleted only from the front end of the queue, A is removed and B is at the front now.

In Fig3 when we are supposed to insert new items D and E then they must be inserted at the rear end of the queue. Since we inserted D before E then at the time of removal D will be first removed…

… from the queue. We can also conclude that the first element inserted in the queue will be the first element to be removed from the queue.

Because of the inserting and removing procedure, it is also named the FIFO(first in first out) list. you can also understand the scenario with a real-life example like a line at the bank cash counter to withdraw money.

One who will come first will go first or will be served first.

Initializing a queue will be the first process to work with a queue. Adding an element to the queue and deleting an element to the queue is the other operation of the queue.

Adding an element to the queue is also known as ENQ, whereas deleting an element to the queue is known as DEQ, these are the popular name given to these operations. A few more popular operations of the queue are given below.

## QUEUE OPERATIONS

**CREATE**(Q): This is used to create an empty queue.

**ENQ**(i): This is used to add a new element I to the rear of the queue and return a new queue.

**DEQ**(Q): This is used to remove the element at the front end of the queue and return the new result queue along with the removed element.

**EMPTY**(Q): It is used for checking whether a queue is empty or not. If the queue is empty then return true else false.

**FRONT**(Q): it returns the front end of the queue without any change in the queue.

**QUEUE SIZE**(Q): It tells us the total number of entries in the queue.

**You can also go through a few more amazing blog links below related to Data Structure:**

**What is a strongly connected graph? / How do you know if a graph is strongly connected…****Graph: Types of the graph in data structure…****AVL Tree In Data Structure…****What is a tree in the data structure…****What is compaction in memory management…****What is garbage collection and how does it work…****Dynamic Memory Management…****Josephus problem & Circular linked list…****What is a circular linked list…****What are the linked lists in the data structure and their types…****What is the priority queue with an example…****the difference between stack and queue…****What is meant by backtracking in the data structure…****You can also check out the difference between Stack vs Queue.****What are the stack and its operations…****How to solve the Tower of Hanoi Problem…****What is recursion with an example…****The complexity of an algorithm…****What are the data structure and its types…****What is the data structure…****What is a queue in a data structure…**

### Conclusion:

Using this blog post(What is a queue in a data structure) we have seen What is a queue in data structures? What are the queue in the data structure and their types? What is the queue explain? What is the queue example? Types of the queue in the data structure, Circular queue in a data structure, Application of queue in the data structure, Stack in the data structure.

In the case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.

Hope! you would have enjoyed this post(What is a queue in a data structure).

Please feel free to give your important feedback in the comment section below|What is a queue in a data structure|

Have a great time!