### 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.

### Difference between stack and queue

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. |

This article tried to discuss the **Difference between Stack and Queue Data Structures**. Hope this blog helps you understand the concept. To practice problems feel free to check MYCODE | Competitive Programming.