In this blog, we will discuss stack and queue in data structures, difference between stack and queue. Stack and Queue are one of the most important linear data structures. Stack works on the principle of LIFO i.e. last in first out whereas queue works on the principle of FIFO i.e. first in first out. Let’s take the baby steps and see our topic “Stack And Queue Difference”, firstly we will discuss stack and queue.

## What is Stack Data Structure?

Stack is a linear data structure in which a user can insert and delete an element from the same end which is known as a top.

Stack data structure follows LIFO property i.e. Last in first out.

In LIFO, the element which was inserted last will be the element which was removed first.

In stack, the process of insertion is called push operation and the process of deletion of the element from the stack is known as pop.

And, we can easily keep track of the last element using a pointer called top.

## What is Queue Data Structure?

A Queue is a linear data structure. Queue follows the FIFO rule i.e. First in First out. In other words we can say the element that goes in first is the element that comes out first.

For Example A ticket Queue outside a cinema hall where the person enters the queue first will get the ticket first.

In a queue, the process of insertion is called enqueue and the process of deletion of the element from the queue is called dequeue.

Now, let’s see the difference between stack and queue in data structures.

## Stack vs Queue

Given below is the table showing stack and queue difference.

Parameters | Stack Data Structure | Queue Data Structure |
---|---|---|

Basics | Stack is a linear data structure. The elements are inserted or removed from the same end. | Queue is also a linear data structure. The elements are inserted or removed from two different ends. |

Working | It follows LIFO (Last in first out) property. | It follows FIFO (First in first out) property. |

Pointers | Stack has only one pointer called top which points the address of the topmost element of the stack | Queue has two pointers i.e. front and rear. |

Operations | Insertion is called push. | Insertion is called enqueue |

Operations | Deletion is called pop. | Deletion is called Dequeue. |

Uses | Stack is used for solving recursive problems | Queue is used for solving sequential problems. |

**Conclusion**

In this blog, we had discussed completely about Stack and Queue, the difference between stack and queue, how stack and queue worked, and discussed the table containing the key points for the stack and queue difference. Stack and Queue are very vast topics in data structures, there are lots more to discover from the outside. Practice more on data structures like stack and queue to become a master in data structures on our platform MYCODE | Competitive Programming.