- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Stack and Queue
In this post, we will understand the difference between Stack and Queue.
They are based on LIFO- Last In First Out.
This means the element inserted at the end is the first element to get deleted.
Insertion and deletion happen in a stack from one end only, i.e the top.
Insert operation is known as ‘push’ operation.
Delete operation is known as ‘pop’ operation.
A pointer is used to access the list, it is known as ‘top’.
The ‘top’ points to the last element of the list.
It helps work with problems associated with recursion.
Representation of Stack (LIFO)
They are based on FIFO- First In First Out.
This means the element that is inserted first is the first element to be deleted from the queue.
Insertion and deletion happen from two opposite ends of the list.
Insertion happens from the rear end.
Deletion happens from the front end.
Insert operation is also known as ‘enqueue’.
Delete operation is also known as ‘dequeue’.
Two pointers are used to access the list.
Front pointer points to first element that is inserted in the list, and still present.
The rear pointer points to the last inserted element of the queue.
It is used to solve problems that have sequential processing techniques.
Representation of Queue
- Difference between Stack and Queue Data Structures
- Differences between stack and queue data structure
- Difference Between Linear Queue and Circular Queue
- Difference Between Stack and Heap
- Stack and Queue in C#
- Stack and Queue in Python using queue Module
- Difference between Stack and Heap memory in Java
- Create a Stack and Queue using ArrayDeque in Java
- Difference between a Static Queue and a Singly Linked List in Java.
- Difference between peek(), poll() and remove() method of Queue interface in java?
- Python Program to Implement Stack using One Queue
- Check if a queue can be sorted into another queue using a stack in Python
- How can we Implement a Stack using Queue in Java?
- How can we Implement a Queue using Stack in Java?
- queue::front() and queue::back() in C++ STL