QA
🧠
Core Engineering

Data Structures & Algorithms Interview Questions

Comprehensive DSA interview questions from beginner fundamentals (Big-O, arrays, stacks) to senior-level topics (Segment Trees, Suffix Arrays, NP-Completeness, Bitmask DP).

🎯 Ready to test your knowledge?

Take Data Structures & Algorithms Skill Assessment Quiz

First prepare from the 100 learning questions below, then test your skills with 15 random MCQs categorized into Beginner, Intermediate, and Senior levels.

Launch 15-MCQ Quiz β†’
Experience Level:

Showing 85 Questions

Beginner LevelData Structures & Algorithms

1. What is the difference between an Array and a Linked List?

❓ Context: Compare Arrays and Linked Lists in terms of memory layout, time complexities for access, insertion, and deletion, and when to prefer each.

Arrays store elements in contiguous memory blocks; Linked Lists store elements in nodes scattered in memory, connected via pointers.

Time Complexity Comparison:

| Operation | Array | Linked List |

|---|---|---|

| Access by index | $O(1)$ | $O(N)$ |

| Search | $O(N)$ | $O(N)$ |

| Insert at head | $O(N)$ (shift) | $O(1)$ |

| Insert at tail | $O(1)$ amortized | $O(N)$ (singly) / $O(1)$ (doubly with tail ptr) |

| Delete at head | $O(N)$ (shift) | $O(1)$ |

When to Use:

β€’
Array: Random index access is frequent; cache locality matters; fixed or slowly growing data.
β€’
Linked List: Frequent insertions/deletions at the head/middle; size is highly dynamic.
typescript
// Singly Linked List Node
class ListNode<T> {
  value: T;
  next: ListNode<T> | null = null;
  constructor(value: T) { this.value = value; }
}

// O(1) head insertion β€” impossible at O(1) with an array
function insertAtHead<T>(head: ListNode<T> | null, value: T): ListNode<T> {
  const node = new ListNode(value);
  node.next = head;
  return node; // new head
}
πŸ’‘O(1) head insertion with a Singly Linked List.
🎯 Interview Key Takeaway

Arrays provide O(1) random access; Linked Lists provide O(1) head insertions. Choose based on the dominant operation in your algorithm.

#DSA#Array#Linked List#Data Structures#Beginner
Permalink
Beginner LevelData Structures & Algorithms

2. What is Big-O Notation and why is it important?

Beginner LevelData Structures & Algorithms

3. What are Stack and Queue data structures and where are they used?

Beginner LevelData Structures & Algorithms

5. How does a Hash Table work internally?

Beginner LevelData Structures & Algorithms

6. Explain Bubble Sort, Selection Sort, and Insertion Sort with their complexities.

Beginner LevelData Structures & Algorithms

7. What is the Two-Pointer Technique?

Beginner LevelData Structures & Algorithms

8. What is the Sliding Window Technique?

Beginner LevelData Structures & Algorithms

9. What is Recursion and how do you identify the Base Case?

Beginner LevelData Structures & Algorithms

10. What is a Binary Tree and what are its key properties?

Beginner LevelData Structures & Algorithms

11. What is a Binary Search Tree (BST) and how do Search, Insert, and Delete work?

Beginner LevelData Structures & Algorithms

12. How do you implement a Queue using two Stacks?

Beginner LevelData Structures & Algorithms

13. How does Merge Sort work and why is it preferred for stable sorting?

Beginner LevelData Structures & Algorithms

14. How do you reverse a string and check if two strings are anagrams?

Beginner LevelData Structures & Algorithms

15. What is the Prefix Sum technique and when is it useful?

Beginner LevelData Structures & Algorithms

16. How do you detect a cycle in a Linked List (Floyd's Algorithm)?

Beginner LevelData Structures & Algorithms

17. How do you validate balanced parentheses using a Stack?

Beginner LevelData Structures & Algorithms

18. What is the difference between Memoization (Top-Down DP) and Tabulation (Bottom-Up DP)?

Beginner LevelData Structures & Algorithms

19. What is the difference between BFS and DFS graph traversal?

Beginner LevelData Structures & Algorithms

20. How does Quick Sort work and what makes it fast in practice?

Beginner LevelData Structures & Algorithms

21. How do you traverse a 2D matrix (row-major, spiral, diagonal)?

Beginner LevelData Structures & Algorithms

22. What are Counting Sort and Radix Sort and when do they beat O(N log N)?

Beginner LevelData Structures & Algorithms

23. How do you find the maximum and minimum in an array with fewest comparisons?

Beginner LevelData Structures & Algorithms

24. How do you check if a number is a Power of Two using bit manipulation?

Beginner LevelData Structures & Algorithms

25. How do you find the first non-repeating character in a string?

Beginner LevelData Structures & Algorithms

26. How do you reverse a Singly Linked List iteratively and recursively?

Beginner LevelData Structures & Algorithms

27. What is the space-optimised Fibonacci solution?

Beginner LevelData Structures & Algorithms

28. How does Kadane's Algorithm find the Maximum Subarray Sum in O(N)?

Beginner LevelData Structures & Algorithms

29. What is a Heap (Min-Heap / Max-Heap) and how is it used as a Priority Queue?

Beginner LevelData Structures & Algorithms

30. How do you find a Missing Number using XOR or Gauss's formula?

Intermediate LevelData Structures & Algorithms

31. How does Backtracking work and how do you generate all Subsets?

Intermediate LevelData Structures & Algorithms

32. What is Topological Sorting and how does Kahn's Algorithm work?

Intermediate LevelData Structures & Algorithms

33. How does Dijkstra's Algorithm find the Shortest Path in a weighted graph?

Intermediate LevelData Structures & Algorithms

34. How do you solve the Coin Change problem with Dynamic Programming?

Intermediate LevelData Structures & Algorithms

35. How do you compute the Longest Common Subsequence (LCS)?

Intermediate LevelData Structures & Algorithms

36. How do you solve the 0/1 Knapsack problem with Dynamic Programming?

Intermediate LevelData Structures & Algorithms

37. What is a Trie (Prefix Tree) and what are its advantages over a hash map for strings?

Intermediate LevelData Structures & Algorithms

38. What is Union-Find (Disjoint Set Union) and how do Path Compression and Union by Rank work?

Intermediate LevelData Structures & Algorithms

39. What is a Segment Tree and when is it better than a Prefix Sum?

Intermediate LevelData Structures & Algorithms

40. What is an AVL Tree and how do rotations maintain balance?

Intermediate LevelData Structures & Algorithms

41. How do you detect a cycle in an undirected and directed graph?

Intermediate LevelData Structures & Algorithms

42. What is a Monotonic Stack and how does it solve Next Greater Element?

Intermediate LevelData Structures & Algorithms

43. How do you solve the Trapping Rain Water problem optimally?

Intermediate LevelData Structures & Algorithms

44. How do you merge K sorted linked lists efficiently?

Intermediate LevelData Structures & Algorithms

45. How do you find the Longest Increasing Subsequence (LIS)?

Intermediate LevelData Structures & Algorithms

46. How do you solve the Word Search problem on a 2D grid using Backtracking?

Intermediate LevelData Structures & Algorithms

47. How do you implement an LRU Cache in O(1) time?

Intermediate LevelData Structures & Algorithms

48. How do you count the Number of Islands in a 2D grid?

Intermediate LevelData Structures & Algorithms

49. What is a Fenwick Tree (Binary Indexed Tree) and how does it work?

Intermediate LevelData Structures & Algorithms

50. How do you find the shortest path in an unweighted grid using BFS?

Intermediate LevelData Structures & Algorithms

51. How do you find the Kth Largest Element in an array efficiently?

Intermediate LevelData Structures & Algorithms

52. How do you compute the Edit Distance (Levenshtein Distance) between two strings?

Intermediate LevelData Structures & Algorithms

53. Explain the K-way Merge pattern and its applications.

Intermediate LevelData Structures & Algorithms

54. How do Kruskal's and Prim's algorithms find the Minimum Spanning Tree?

Intermediate LevelData Structures & Algorithms

55. How does the Dutch National Flag algorithm sort an array of 0s, 1s, and 2s in O(N)?

Senior LevelData Structures & Algorithms

56. How does Bellman-Ford detect negative cycles in a weighted graph?

Senior LevelData Structures & Algorithms

57. How does Floyd-Warshall solve All-Pairs Shortest Paths?

Senior LevelData Structures & Algorithms

58. How does Kosaraju's Algorithm find Strongly Connected Components?

Senior LevelData Structures & Algorithms

59. What is a Suffix Array and how is it used for pattern matching?

Senior LevelData Structures & Algorithms

60. What are the properties of a Red-Black Tree and why is it preferred over AVL?

Senior LevelData Structures & Algorithms

62. What is Heavy-Light Decomposition (HLD) and what problems does it solve?

Senior LevelData Structures & Algorithms

63. What is a Persistent Segment Tree and when is it necessary?

Senior LevelData Structures & Algorithms

64. How does Ford-Fulkerson compute Maximum Flow in a network?

Senior LevelData Structures & Algorithms

65. How do you solve Matrix Chain Multiplication using Dynamic Programming?

Senior LevelData Structures & Algorithms

66. How do you find Articulation Points and Bridges in a graph?

Senior LevelData Structures & Algorithms

67. How does Graham Scan compute the Convex Hull in O(N log N)?

Senior LevelData Structures & Algorithms

68. What is Bitmask Dynamic Programming and how does it solve the Travelling Salesman Problem?

Senior LevelData Structures & Algorithms

69. What is Mo's Algorithm for offline range queries?

Senior LevelData Structures & Algorithms

70. How does Binary Lifting solve Lowest Common Ancestor (LCA) queries in O(log N)?

Senior LevelData Structures & Algorithms

71. How does the Aho-Corasick Algorithm enable multi-pattern string matching?

Senior LevelData Structures & Algorithms

72. What is Reservoir Sampling and how does it select K items uniformly from a stream?

Senior LevelData Structures & Algorithms

73. What is a Skip List and how does it achieve O(log N) operations probabilistically?

Senior LevelData Structures & Algorithms

74. What is a Treap (Tree + Heap) and how does it maintain expected O(log N) height?

Senior LevelData Structures & Algorithms

75. What is Square Root Decomposition and when is it used?

Senior LevelData Structures & Algorithms

76. Explain Amortised Analysis with Aggregate, Accounting, and Potential methods.

Senior LevelData Structures & Algorithms

77. What are P, NP, NP-Complete, and NP-Hard complexity classes?

Senior LevelData Structures & Algorithms

78. How do you count Inversions in an array using modified Merge Sort?

Senior LevelData Structures & Algorithms

79. How does Rabin-Karp Hashing enable efficient substring search?

Senior LevelData Structures & Algorithms

80. How do Cache-Efficient Algorithms and Memory Hierarchy affect real-world performance?

Senior LevelData Structures & Algorithms

81. What is the difference between Online and Offline algorithms?

Senior LevelData Structures & Algorithms

82. How does a Sparse Table enable O(1) Range Minimum Queries?

Senior LevelData Structures & Algorithms

83. How does an Euler Tour flatten a tree for efficient subtree queries?

Senior LevelData Structures & Algorithms

84. How does the Master Theorem solve Divide-and-Conquer recurrences?

Senior LevelData Structures & Algorithms

85. What is Sum over Subsets (SOS) Dynamic Programming?

How to Prepare for Data Structures & Algorithms Technical Interviews in 2026

When interviewing for software engineering positions that utilize Data Structures & Algorithms, hiring managers look for a combination of fundamental syntax proficiency, architectural understanding, code optimization techniques, and practical debugging skills.

🌱 Beginner FocusCore syntax, default configurations, standard API definitions, and avoiding common basic errors.
⚑ Intermediate FocusAsync execution patterns, performance profiling, component lifecycle, and state management.
πŸ† Senior FocusInternal runtime mechanics, memory leaks, scalability bottlenecks, system design trade-offs, and security mitigation.