DSA for placements: interview questions by topic
At the placement stage, data structures and algorithms are not competitive programming. The interviewer wants to see whether you recognise the shape of a problem and reach for the right tool: two pointers on a sorted array, a hash map to replace a nested loop, a stack for matching brackets or the nearest greater element, breadth-first search for the shortest path on an unweighted graph, recursion with a base case you can state out loud. Then the follow-up that decides the round — what is the time complexity, and can you do better?
Sorting and binary search are the foundation and the most common source of off-by-one mistakes. Linked lists come up as reversal and cycle detection, trees as traversals and the BST property, hashing as the answer to almost every 'find the pair' question, and bit manipulation as the odd question that checks whether you know what the machine is doing. Strings are arrays with extra rules.
Each page below covers one topic: the questions that are actually asked, the answers with code, the complexity said plainly, and one question exactly as the diagnostic asks it. The diagnostic draws from every DSA topic in the bank and names the ones you missed.
DSA topics, one page each
12 of the 14 DSA topics in the bank have a page so far; the diagnostic draws from all 14.
- Sorting algorithm interview questions
Complexity of every sorting algorithm, stability, when quicksort degrades, merge sort for linked lists, the n log n lower bound — answered for placements.
- Binary tree and BST interview questions
Binary tree vs BST, traversals, height vs depth, why balanced trees give O(log n), validating a BST, lowest common ancestor, level order — with code.
- Linked list interview questions
Reverse a list, detect a cycle and find its start, middle node in one pass, nth from the end, delete without the head, merge, LRU cache — with code.
- Stack and queue interview questions
Balanced brackets, a queue from two stacks, a stack from queues, min stack, circular queue, infix to postfix, monotonic deque — answered.
- Binary search interview questions
Why it is O(log n), the overflow-safe midpoint, first and last occurrence, rotated arrays, binary search on the answer, loops that never hang.
- Hashing and hash table interview questions
How a hash table gets O(1), collisions, chaining vs open addressing, load factor and resizing, hashCode and equals, HashMap vs TreeMap — answered.
- Recursion and backtracking interview questions
Base cases, the call stack and overflow, recursion vs iteration, memoisation, counting calls, the backtracking template, pruning, subsets and N-Queens.
- Time and space complexity interview questions
Big-O explained, the common classes in order, loops and nested loops, where log n comes from, recurrences, space including the stack, amortised cost.
- Bit manipulation interview questions
AND, OR, XOR and shifts, odd/even and powers of two, n & (n-1), counting set bits, the XOR trick, get/set/clear a bit, two's complement and shifts.
- Array and two-pointer interview questions
Which array operations are O(1), in-place reversal, pair sum in a sorted array, removing duplicates, sliding windows, Kadane, Dutch flag, majority element.
- String interview questions
Why strings are immutable and what it costs, StringBuilder, palindromes, anagrams, first non-repeating character, reversing words, KMP, compression.
- Graph interview questions
Adjacency list vs matrix, BFS vs DFS and when to use each, shortest path unweighted, cycle detection directed and undirected, topological sort, Dijkstra.
One question, exactly as the diagnostic asks it
From the DSA bank — 67 questions across 14 topics. The answer is marked because this one is public; in a sitting you choose first, then see why each option is right or wrong.
Which of the following operations on an unsorted array of n integers takes O(n) time in the worst case?
- 1Finding the maximum elementcorrect
- 2Appending an element at the end when spare capacity already exists
- 3Reading the element at index k
- 4Reading the array's length
In an unsorted array the maximum could be anywhere, so every element must be examined: O(n). Indexed reads are O(1) because the address is computed from the base and the index; appending into existing spare capacity just writes one slot, O(1); and the length is stored, so reading it is O(1). Only a sorted array would let the maximum be read directly.
Measure it
Reading the answers tells you what’s true. A diagnostic tells you what you get wrong.
10 DSA questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: 1 diagnostic a month and 15 problems a day. No card.