Queue Data Structure
Data Structure and Algorithms Course
Practice Problems on Queue
Recent articles on Queue
What is Queue Data Structure?
A Queue is defined as a linear data structure that is open at both ends and the operations are performed in First In First Out (FIFO) order.
We define a queue to be a list in which all additions to the list are made at one end, and all deletions from the list are made at the other end. The element which is first pushed into the order, the operation is first performed on that.
FIFO Principle of Queue:
- A Queue is like a line waiting to purchase tickets, where the first person in line is the first person served. (i.e. First come first serve).
- Position of the entry in a queue ready to be served, that is, the first entry that will be removed from the queue, is called the front of the queue(sometimes, head of the queue), similarly, the position of the last entry in the queue, that is, the one most recently added, is called the rear (or the tail) of the queue. See the below figure.
Characteristics of Queue:
- Queue can handle multiple data.
- We can access both ends.
- They are fast and flexible.
Queue Representation:
Like stacks, Queues can also be represented in an array: In this representation, the Queue is implemented using the array. Variables used in this case are
- Queue: the name of the array storing queue elements.
- Front: the index where the first element is stored in the array representing the queue.
- Rear: the index where the last element is stored in an array representing the queue.
Topics :
Introduction to Queue Data Structure:
- Introduction to Queue – Data Structure and Algorithm Tutorials
- Implementations of Queue Data Structure using Arrays
- Implementations of Queue Data Structure using Linked List
- Applications, Advantages and Disadvantages of Queue
- Different Types of Queue
Implementation of Queue in various Programming Languages:
- Queue in C++ Standard Template Library (STL)
- Queue Interface In Java
- Queue In Python
- Queue In C#
- Queue in Javascript
- Queue in Go Language
- Queue in Scala

Some other Implementations of Queue Data Structure:
- Implementation of Deque using doubly linked list
- Implement a stack using single queue
- Implement Queue using Stacks
- Implement Stack using Queues
- How to efficiently implement k Queues in a single array?
- LRU Cache Implementation
Some Must Solve Standard Problems on Queue Data Structure:
- Easy:
- Queue – Linked List Implementation
- Implement Stack using Queues
- Queue using Stacks
- Detect cycle in an undirected graph using BFS
- Breadth First Search or BFS for a Graph
- Traversing directory in Java using BFS
- Vertical order traversal of Binary Tree using Map
- Print Right View of a Binary Tree
- Find Minimum Depth of a Binary Tree
- Difference between BFS and DFS
- Check whether a given graph is Bipartite or not
- Find the Maximum Depth or Height of given Binary Tree
- Medium:
- Flatten a multilevel linked list
- Level with maximum number of nodes
- Find if there is a path between two vertices in a directed graph
- Queue using Stacks
- Implement Stack using Queues
- Print all nodes between two given levels in Binary Tree
- Minimum steps to reach target by a Knight
- Islands in a graph using BFS
- Deletion in a Binary Tree
- Level order traversal line by line | Set 3 (Using One Queue)
- Clockwise Spiral Traversal of Binary Tree
- Reverse Level Order Traversal
- Perfect Binary Tree Specific Level Order Traversal
- Print Left View of a Binary Tree
- Check whether a given Binary Tree is Complete or not
- Diagonal Traversal of Binary Tree
- Print leftmost and rightmost nodes of a Binary Tree
- Convert a Binary Tree into Doubly Linked List in spiral fashion
- Check if a given Binary Tree is a Heap
- Reverse alternate levels of a perfect binary tree
- Hard:
- Sliding Window Maximum (Maximum of all subarrays of size K)
- Flood Fill Algorithm
- Find shortest safe route in a path with landmines
- Shortest path in a Binary Maze
- An Interesting Method to Generate Binary Numbers from 1 to n
- Maximum cost path from source node to destination
- Convert BST to Min Heap
- Shortest distance between two cells in a matrix or grid
- Find next right node of a given key
- Snake and Ladder Problem
- Find shortest safe route in a path with landmines
- Maximum cost path from source node to destination
- Count all possible walks from a source to a destination …
- Minimum Cost of Simple Path between two nodes in a …
- Traversing directory in Java using BFS
- Minimum Cost Path in a directed graph via given set of …
- LRU Cache Implementation
- Find the first circular tour that visits all petrol pumps
- Find the first non-repeating character from a stream of characters
- Sliding Window Maximum (Maximum of all subarrays of size K)
- Minimum time required to rot all oranges
GeeksforGeeks Courses:
Complete Interview Preparation
Prepare for a job interview with confidence and clarity, Here you’ll get prepared for each and every subject & skill relevant to the interview whether it be core CS subjects, programming language, reasoning & aptitude, resume building, etc. at budget-friendly prices with GeeksforGeeks Complete Interview Preparation Course.
Live Courses
Enrol today to learn data structures, Get best-in-industry real-time GFG Live Courses to upskill yourself and get into your dream company. You can attend these live classes from any geographical region and here you can ask your doubts to the instructor just like an offline classroom program. Do check out these valuable Live Courses by GeeksforGeeks – System Design Live, Competitive Programming Live, and more!
Language Foundation Courses[ C Programming / C++ / JAVA / Python ]
Each language is designed to get you right into hands-on practice by offering Language Foundation Courses. Learn any programming language from scratch and understand all its fundamental concepts for a strong programming foundation in the easiest possible manner at best price possible with help of GeeksforGeeks Language Foundation Courses –
C Programming | Java Foundation | Python Foundation | C++ Foundation.
Recomended:






