Queue Data Structure: Practice Problems and Interview Questions
Published in
3 min readDec 25, 2018
A Queue is a linear First-In-First-Out (FIFO) data structure which means that the first element added to the queue will be the first one to be removed. Therefore, once a new element is added to the queue, all elements that were added before have to be removed before the new element can be removed.
In this post, we have listed out commonly asked interview questions that use queue data structure:
- Queue implementation using an array — C, C++, Java, Python
- Queue Implementation using a Linked List
- Implement a stack using the queue data structure
- Implement a queue using the stack data structure
- Efficiently print all nodes between two given levels in a binary tree
- Chess Knight Problem | Find the shortest path from source to destination
- Shortest path in a maze — Lee Algorithm
- Find the shortest safe route in a field with sensors present
- Flood Fill Algorithm
- Count number of islands
- Find the shortest path from source to destination in a matrix that satisfies given constraints
- Generate binary numbers between 1 to `n` using a queue
- Calculate the height of a binary tree
- Delete a binary tree
- Level order traversal of a binary tree
- Spiral order traversal of a binary tree
- Reverse level order traversal of a binary tree
- Print all nodes of a perfect binary tree in a specific order
- Print left view of a binary tree
- Find the next node at the same level as the given node in a binary tree
- Check if a binary tree is a complete binary tree or not
- Print diagonal traversal of a binary tree
- Print corner nodes of every level in a binary tree
- Invert Binary Tree
- Find minimum passes required to convert all negative values in a matrix
- Convert a binary tree into a doubly-linked list in spiral order
- Check if a binary tree is a min-heap or not
- Invert alternate levels of a perfect binary tree
- Convert a Binary Search Tree into a Min Heap
- Snake and Ladder Problem
- Find the shortest distance of every cell from a landmine inside a maze
- Convert a multilevel linked list to a singly linked list
- Check if an undirected graph contains a cycle or not
- Find maximum cost path in a graph from a given source to a given destination
- Total paths in a digraph from a given source to a destination having exactly `m` edges
- Least cost path in a digraph from a given source to a destination having exactly `m` edges
- Breadth-First Search (BFS)
- Traverse a given directory using BFS and DFS in Java
- Perform vertical traversal of a binary tree
- Compute the maximum number of nodes at any level in a binary tree
- Print right view of a binary tree
- Find the minimum depth of a binary tree
- Depth-First Search (DFS) vs Breadth-First Search (BFS)
- Bipartite Graph
- Compute the least cost path in a weighted digraph using BFS
- Find the path between given vertices in a directed graph
- Construct a directed graph from an undirected graph that satisfies given constraints
- Print nodes of a binary tree in vertical order
Thanks for reading.