20 topics

Data structures and algorithms help, starting with which one to reach for

The exam question is rarely implement a hash table. It is which structure would you use here, and why — and the answer comes from one habit: list the operations the problem actually performs, then count how often each one runs. A structure with fast lookup and slow insertion is the right choice when you look up a thousand times and insert once, and the wrong one when the ratio flips.

Where students get stuck

I can implement them all but I cannot pick one

Write down the operations the problem needs and how many times each happens, then match them to costs. Lookup by key many times means a hash map at O(1) average. Needing the smallest item repeatedly means a heap at O(log n) rather than sorting every round. Frequent insertion and deletion in the middle of a sequence means a linked list, since an array has to shift everything after the point. Needing items in sorted order as you go means a balanced tree, because a hash map cannot give you order at all.

My binary search tree is O(n), not O(log n)

It is unbalanced. A BST only gives logarithmic behaviour when the tree is roughly the same depth on both sides, and inserting already-sorted data produces one long right spine — a linked list with extra pointers. That is why AVL and red-black trees exist: they rebalance on insertion so height stays proportional to log n. For an assignment, either shuffle the input before inserting, or use the balanced structure your standard library provides and say in your write-up why the naive version degrades.

Recursion works on small inputs then overflows the stack

Each call keeps a frame on the call stack, so depth proportional to n dies somewhere in the low thousands. The question is whether the recursion is deep or wide. A tree that splits the problem in half has depth log n and is safe. A recursion that removes one element per call has depth n and is not, so rewrite that one as a loop. If it is the same subproblem being recomputed instead — naive Fibonacci is the standard example — the problem is not depth but repeated work, and memoisation fixes it.

Two loops but the answer is O(n), not O(n squared)

Nested loops are not automatically quadratic. In the sliding-window and two-pointer patterns each pointer only ever moves forward, so across the whole run the inner loop advances at most n times in total, not n times per outer step. Count total pointer movement rather than loop nesting. The same reasoning gives amortised O(1) for appending to a dynamic array: the doubling copy is O(n), but it happens rarely enough that the cost spread over all appends is constant.

I cannot see where to start a dynamic programming problem

Do not start from the table. Start by writing the plain recursive solution, however slow, because that forces you to state the subproblem. Then look at what its arguments are: those are your table dimensions. Then note which calls repeat, and cache them. Only once that memoised version is correct should you turn it inside out into a bottom-up loop, and the loop order is just whatever ordering guarantees a smaller subproblem is filled before the one that depends on it.

What's covered

Data Structures & Algorithms topics you can work through with a tutor, generate practice on, or turn into flashcards and a study plan.

Linear structures

  • Dynamic arrays, amortised resizing, and cache behaviour
  • Singly and doubly linked lists
  • Stacks and their use in parsing and backtracking
  • Queues, deques, and circular buffers

Maps, sets, and trees

  • Hash functions, collisions, chaining, and open addressing
  • Binary search trees: insert, delete, and traversal orders
  • Balanced trees: AVL rotations and red-black properties
  • Heaps and priority queues
  • Tries and prefix search

Algorithms

  • Binary search and its boundary conditions
  • Sorting: merge, quick, heap, and counting sort
  • Graph traversal with BFS and DFS
  • Shortest paths: Dijkstra and Bellman-Ford
  • Greedy algorithms and exchange arguments
  • Dynamic programming: memoisation and tabulation

Analysis and proof

  • Big-O, big-Omega, and big-Theta
  • Best, average, and worst case
  • Space complexity and recursion stack depth
  • Recurrence relations and the master theorem
  • Proving correctness with loop invariants

Data Structures & Algorithms questions

I need this for technical interviews rather than a course. Does that work?

Yes, though the practice looks different. Interviews test whether you can narrate a solution out loud while writing it, so a voice session where you talk through the approach before touching code is closer to the real thing than solving problems silently. It will interrupt with the follow-up questions an interviewer asks, like what happens if the input is empty.

Can it give me the answer to a graded problem set?

It is built not to. Algorithms courses are the easiest place to fake understanding and the hardest place to hide it in an exam, so the session works by asking what you have tried and where the reasoning stops. If you want a worked solution to study from, ask for a similar problem instead and it will build one with the full derivation.

How do I revise complexity analysis when it is all so abstract?

The whiteboard helps more than reading does. Working a recurrence out line by line, or drawing the recursion tree and counting the work per level, makes the master theorem stop being a formula to memorise. Flashcards then work well for the fixed facts — the costs of each operation on each structure — since those genuinely are recall.

Does it help with proofs, or only with code?

Both. Loop invariants and exchange arguments are where most marks are lost on an algorithms paper, because students describe what the algorithm does instead of proving it must be correct. It works through the three parts of an invariant proof — initialisation, maintenance, termination — against your specific loop.

Stuck on data structures & algorithms right now?

Talk it through out loud, share your screen, and watch it worked out step by step on a whiteboard.

Start free — no card