100 Data Structures Interview Questions (Topic-Wise)

0
13
data structures interview questions
data structures interview questions

Data Structures are considered to be the important part when it comes to a software development interviews. In this blog we are covering top 100 data structures interview questions that is really helpful for you to start with your coding journey.

As data structures are not restricted to any single programming language as we can apply it anywhere and also said to be a building block for any developer or logical person.

100 Data Structures Interview Questions

Let us explore different questions based on data structures starting with arrays, linked lists, stacks & queues, trees and graph. The First data structure to cover with is the basic data structure array which is also helpful in implementing other data structures also.

data structures interview questions

Array Data Structure Interview Questions

Here is the list of 20 interview questions depends upon array that help you to crack interview of any startup, MNC and product based companies that is pronounced as MAANG.

  1. Find the maximum and minimum element in an array
  2. Reverse an array
  3. Find the “Kth” maximum and minimum element
  4. Move all zeros to the end of the array
  5. Check if an array is sorted
  6. Kadane’s Algorithm – Maximum subarray sum
  7. Find the intersection of two sorted arrays
  8. Sort an array of 0s, 1s, and 2s (Dutch National Flag problem)
  9. Find the longest subarray with sum equal to 0
  10. Subarray with given sum (Sliding Window Technique)
  11. Find duplicate number in an array of N+1 integers
  12. Merge two sorted arrays without extra space
  13. Minimum number of jumps to reach the end of the array
  14. Find the missing number from an array containing numbers from 1 to N
  15. Maximum product subarray
  16. Count inversions in an array (using Merge Sort)
  17. Median of two sorted arrays
  18. Trapping Rain Water problem
  19. Find all subarrays with XOR = K
  20. Maximum sum of i*arr[i] among all rotations of a given array

Linked List Data Structure Interview Questions

Below is the list of 20 interview questions depends upon a linked list that help you to crack interview of any startup, MNC and product based companies that is pronounced as MAANG.

  1. Reverse a linked list
  2. Detect a cycle in a linked list (Floyd’s Cycle Detection)
  3. Find the middle of the linked list
  4. Merge two sorted linked lists
  5. Remove N-th node from the end of the list
  6. Detect and remove a loop in a linked list
  7. Find the intersection point of two linked lists
  8. Check if a linked list is a palindrome
  9. Rotate a linked list by k positions
  10. Remove duplicates from a sorted linked list
  11. Delete a node without head pointer
  12. Add two numbers represented by linked lists
  13. Clone a linked list with random pointers
  14. Flatten a multilevel linked list
  15. Sort a linked list using Merge Sort
  16. Reverse nodes in k-group
  17. Merge K sorted linked lists
  18. Intersection of two sorted linked lists
  19. Convert binary number in a linked list to integer
  20. Swap nodes in pairs

Stacks & Queues Data Structures Interview Questions

Stacks and queues are important concept when we are talking about interviews and here covers combined questions of stacks and queues.

  1. Implement a stack using arrays or linked list
  2. Implement two stacks in one array
  3. Design a stack that supports getMin() in O(1) time
  4. Evaluate postfix expression
  5. Infix to postfix conversion
  6. Next Greater Element
  7. Largest rectangle in a histogram
  8. Celebrity problem (using stack)
  9. Valid parenthesis checker
  10. Sort a stack using recursion
  11. Implement a queue using stacks
  12. Implement a circular queue
  13. LRU Cache (using Doubly Linked List + HashMap)
  14. First non-repeating character in a stream
  15. Rotten oranges (multi-source BFS using queue)
  16. Generate binary numbers from 1 to N using a queue
  17. Interleave the first half of the queue with second half
  18. Reverse the first K elements of a queue
  19. Sliding window maximum (Monotonic queue)
  20. Implement a deque (double-ended queue)

Tree Data Structure Interview Questions

Here is a combined list of 20 MAANG-level Tree Data Structure interview question headings that covering Binary Trees, Binary Search Trees (BSTs), and Advanced Trees.

  1. Inorder, Preorder, and Postorder Traversals (recursive & iterative)
  2. Level Order Traversal (BFS using Queue)
  3. Height/Depth of a Binary Tree
  4. Check if a Binary Tree is Balanced
  5. Diameter of a Binary Tree
  6. Lowest Common Ancestor (LCA) in a Binary Tree
  7. Convert Sorted Array to Balanced BST
  8. Check if two trees are identical
  9. Zigzag (Spiral) Level Order Traversal
  10. Boundary Traversal of a Binary Tree
  11. Vertical Order Traversal of a Binary Tree
  12. Top View / Bottom View of a Binary Tree
  13. Serialize and Deserialize a Binary Tree
  14. Construct Binary Tree from Inorder and Preorder Traversal
  15. Path Sum Problems (Has path sum / Find all paths with sum)
  16. Mirror a Binary Tree
  17. Flatten a Binary Tree to Linked List
  18. Validate a Binary Search Tree (BST)
  19. Kth Smallest/Largest Element in a BST
  20. Find Distance Between Two Nodes in a Binary Tree

Graph Data Structure Interview Questions

Here is a combined list of 20 MAANG-level Graph Data Structure interview question headings including BFS, DFS, shortest path, cycle detection and other advanced concepts.

  1. Represent a graph using adjacency list/matrix
  2. Depth First Search (DFS)
  3. Breadth First Search (BFS)
  4. Detect cycle in an undirected graph (DFS/Union-Find)
  5. Detect cycle in a directed graph (DFS + Recursion Stack)
  6. Topological Sort (Kahn’s algorithm / DFS)
  7. Number of connected components in a graph
  8. Check if a graph is bipartite
  9. Clone a graph
  10. Shortest path in an unweighted graph (BFS)
  11. Dijkstra’s Algorithm for shortest path in weighted graph
  12. Bellman-Ford Algorithm
  13. Floyd-Warshall Algorithm (All-pairs shortest path)
  14. Kruskal’s Algorithm (Minimum Spanning Tree using Union-Find)
  15. Prim’s Algorithm (Minimum Spanning Tree using Priority Queue)
  16. Course Schedule problem (Cycle Detection + Topological Sort)
  17. Word Ladder problem (BFS)
  18. Alien Dictionary (Graph + Topological Sort)
  19. Strongly Connected Components (Kosaraju’s algorithm)
  20. Bridges and Articulation Points in a Graph (Tarjan’s algorithm)

Conclusion

We have covered 100 data structures interview questions and level starting from very basics till advanced that will help you to cover software development interview or other that are related to the technical field.