Queue Data Structure: Practice Problems and Interview Questions

Vivek Srivastava
Techie Delight
3 min readDec 25, 2018

--

Queue Data Structure

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:

  1. Queue implementation using an array — C, C++, Java, Python
  2. Queue Implementation using a Linked List
  3. Implement a stack using the queue data structure
  4. Implement a queue using the stack data structure
  5. Efficiently print all nodes between two given levels in a binary tree
  6. Chess Knight Problem | Find the shortest path from source to destination
  7. Shortest path in a maze — Lee Algorithm
  8. Find the shortest safe route in a field with sensors present
  9. Flood Fill Algorithm
  10. Count number of islands
  11. Find the shortest path from source to destination in a matrix that satisfies given constraints
  12. Generate binary numbers between 1 to `n` using a queue
  13. Calculate the height of a binary tree
  14. Delete a binary tree
  15. Level order traversal of a binary tree
  16. Spiral order traversal of a binary tree
  17. Reverse level order traversal of a binary tree
  18. Print all nodes of a perfect binary tree in a specific order
  19. Print left view of a binary tree
  20. Find the next node at the same level as the given node in a binary tree
  21. Check if a binary tree is a complete binary tree or not
  22. Print diagonal traversal of a binary tree
  23. Print corner nodes of every level in a binary tree
  24. Invert Binary Tree
  25. Find minimum passes required to convert all negative values in a matrix
  26. Convert a binary tree into a doubly-linked list in spiral order
  27. Check if a binary tree is a min-heap or not
  28. Invert alternate levels of a perfect binary tree
  29. Convert a Binary Search Tree into a Min Heap
  30. Snake and Ladder Problem
  31. Find the shortest distance of every cell from a landmine inside a maze
  32. Convert a multilevel linked list to a singly linked list
  33. Check if an undirected graph contains a cycle or not
  34. Find maximum cost path in a graph from a given source to a given destination
  35. Total paths in a digraph from a given source to a destination having exactly `m` edges
  36. Least cost path in a digraph from a given source to a destination having exactly `m` edges
  37. Breadth-First Search (BFS)
  38. Traverse a given directory using BFS and DFS in Java
  39. Perform vertical traversal of a binary tree
  40. Compute the maximum number of nodes at any level in a binary tree
  41. Print right view of a binary tree
  42. Find the minimum depth of a binary tree
  43. Depth-First Search (DFS) vs Breadth-First Search (BFS)
  44. Bipartite Graph
  45. Compute the least cost path in a weighted digraph using BFS
  46. Find the path between given vertices in a directed graph
  47. Construct a directed graph from an undirected graph that satisfies given constraints
  48. Print nodes of a binary tree in vertical order

Thanks for reading.

--

--