DSA questions are less about trivia than about how someone reasons about tradeoffs and complexity. These check for real understanding, not memorised solutions.
Hiring a Data Structures & Algorithms developer is easy. Telling a real one from a convincing résumé is the hard part — and it’s most of what we do. These are grouped by level, because the same question that stretches a junior is a warm-up for a senior.
Junior Data Structures & Algorithms interview questions
0–2 years
Fundamentals.
What is Big-O notation?
A description of how an algorithm’s time or space grows with input size, focusing on the dominant term for the worst case.
Confuses Big-O with actual runtime in seconds.
What is the difference between an array and a linked list?
Arrays give O(1) indexed access and cache locality; linked lists give O(1) insertion/deletion at known positions but O(n) access.
Cannot say when each is preferable.
How does a hash table work?
Keys are hashed to buckets for average O(1) lookup/insert; collisions are resolved by chaining or probing.
Thinks hash lookups are always O(1) with no collision awareness.
What is the difference between a stack and a queue?
A stack is LIFO, a queue is FIFO; each suits different problems (undo vs scheduling).
Confuses their ordering.
What is recursion and what does it need?
A function calling itself with a base case to terminate; without one it recurses forever and overflows the stack.
Writes recursion with no base case.
What is the time complexity of common operations on a hash set?
Average O(1) for add/contains/remove, degrading to O(n) with poor hashing or many collisions.
Assumes it’s always constant.
What is a binary search and its requirement?
Repeatedly halving a sorted range to find a value in O(log n); it requires the data to be sorted.
Applies binary search to unsorted data.
What is the difference between O(n) and O(n^2)?
Linear scales proportionally; quadratic scales with the square, so nested loops over the same data get slow fast.
Writes accidental nested loops without noticing the cost.
Mid-level Data Structures & Algorithms interview questions
2–5 years
Trees, graphs and sorting.
What is a binary search tree and its complexity?
A tree keeping order for O(log n) search/insert when balanced, degrading to O(n) when skewed.
Ignores that an unbalanced BST degrades to a list.
What is the difference between BFS and DFS?
Breadth-first explores level by level (shortest path in unweighted graphs); depth-first goes deep first (good for connectivity, cycles).
Uses the wrong traversal for shortest path.
When would you use a heap?
For efficiently getting the min/max repeatedly — priority queues, top-k, scheduling — with O(log n) insert/extract.
Sorts repeatedly instead of using a heap.
What is dynamic programming?
Solving problems by combining solutions to overlapping subproblems, caching results (memoisation/tabulation) to avoid recomputation.
Cannot recognise overlapping subproblems.
What is the difference between O(1) and O(log n) space?
Constant extra memory versus memory growing logarithmically (e.g. recursion depth in balanced trees).
Ignores the space cost of recursion.
How do you detect a cycle in a linked list?
Fast/slow pointers (Floyd’s algorithm) meet if a cycle exists, using O(1) space.
Uses O(n) extra space unnecessarily.
What are stable vs unstable sorts?
Stable sorts preserve equal elements’ relative order; it matters when sorting by multiple keys.
Unaware stability affects multi-key sorting.
How do you choose the right data structure?
By the operations you need most (lookup, ordering, range queries) and their complexity, plus memory constraints.
Reaches for the same structure regardless of the problem.
Senior Data Structures & Algorithms interview questions
5+ years
Analysis and tradeoffs.
How do you analyse and improve an algorithm’s complexity?
Identify the dominant cost, replace expensive operations with better structures (hashing, sorting, heaps), and trade space for time when it pays.
Optimises constants while ignoring an O(n^2) core.
What is amortised analysis?
Averaging cost over a sequence of operations, e.g. dynamic array append is O(1) amortised despite occasional O(n) resizes.
Judges dynamic array append as always O(n).
How do you approach a problem you haven’t seen?
Clarify constraints, work an example, find a brute force, then optimise with the right structure — reasoning aloud about tradeoffs.
Jumps to code without understanding constraints.
When is a brute-force solution acceptable?
When input sizes are small, clarity matters, or it’s a correct baseline before optimising; premature optimisation wastes effort.
Over-engineers a solution for tiny inputs.
How do graph algorithms apply to real systems?
Shortest paths, dependency resolution, recommendations and network analysis all map to graph traversal and search.
Can’t connect graph theory to practical problems.
How do you reason about space–time tradeoffs?
Caching, precomputation and indexing trade memory for speed; the right choice depends on constraints and access patterns.
Optimises time with no regard for memory limits.
Why do algorithm skills matter beyond interviews?
They shape everyday decisions about data structures, query patterns and scalability that determine whether systems hold up under load.
Dismisses DSA as interview-only trivia.
How do you validate correctness and complexity of a solution?
Reason about edge cases, test systematically, and analyse worst-case behaviour rather than trusting a passing example.
Assumes one passing case proves correctness.
Build and score a full interview with our free interview scorecard tool, browse the full question hub, or see how we interview engineers.