Data structures and algorithms roadmap

Every stage in order, from Big-O through trees, graphs, sorting, recursion and dynamic programming, ending with the patterns that coding interviews draw on.

Stages
14
Topics
70
Core
41
Done
0
Path
Level

Core and recommended topics. Optional ones stay hidden until you have some real work behind you.

  • Core: needed for most jobs of this kind
  • Recommended: worth learning early
  • Optional: learn it when your work needs it

Stage 1

Complexity and Big-O

Big-O notation describes how the running time or memory of an algorithm grows with the size of its input. It lets you compare approaches before running them, and it is the language the rest of this roadmap uses.

Stage 2

Arrays and strings

An array stores elements next to each other in memory, so reading any index takes constant time. Strings behave like arrays of characters with a few quirks of their own. Two pointers and sliding windows, both covered here, solve a large share of interview problems.

Stage 3

Hashing

A hash table gives average constant-time lookups, but collisions, resizing and a poor hash function can make it much slower. Knowing how it works tells you when that average holds.

Stage 4

Linked lists, stacks and queues

A linked list gives up constant-time indexing in exchange for constant-time insertion at a known node, and it makes you work with pointers. Stacks (last in, first out) and queues (first in, first out) are restricted lists used in recursion, parsing and scheduling.

Stage 5

Trees and binary search trees

Trees are where recursion becomes practical. A balanced binary search tree gives O(log n) lookups, and one built from sorted input becomes a list with O(n) lookups. Most tree problems build on the four standard traversals.

Stage 6

Heaps and priority queues

A heap keeps the smallest (or largest) item at the root and restores that order in O(log n) after each change. Problems that ask for the k largest items, the next event, or a merge of several sorted lists usually call for one.

Stage 7

Balanced and specialised trees

A plain binary search tree can become unbalanced. Red-black trees and B-trees rebalance on every write to guarantee O(log n), and tries and segment trees are built for one specific kind of query.

Stage 8

Graphs and traversal

When a problem involves connections, such as friendships, dependencies, roads or states, it can be modelled as a graph. Choose a representation, then use breadth-first or depth-first search; many graph problems in interviews come down to one of the two.

Stage 9

Shortest paths and other graph algorithms

With weights on the edges, traversal becomes optimisation. Dijkstra, Bellman-Ford, A* and the max-flow algorithms each make specific assumptions about the graph and have a known cost.

Stage 10

Sorting and searching

You will rarely write a sort by hand. It still helps to know why quicksort is usually fastest, when merge sort is the better choice, and where binary search goes wrong at the boundaries.

Stage 11

Recursion and backtracking

A recursive function solves a problem by calling itself on a smaller version, with a base case to stop. Backtracking is recursion that tries choices and undoes the ones that fail, which is how permutations, Sudoku solvers and the N-Queens puzzle work.

Stage 12

Dynamic programming

Dynamic programming is the topic candidates find hardest. It is recursion where each subproblem is solved once and stored. The skill is spotting repeated subproblems and choosing a state that holds everything the next step needs.

Stage 13

Greedy algorithms and divide and conquer

A greedy algorithm takes the best-looking option at each step. For some problems that gives the optimal answer, and for others it fails. Divide and conquer splits a problem, solves the parts and combines them. Both are fast because they avoid exploring every possibility.

Stage 14

Interview patterns and practice

Once you know the structures and algorithms, the remaining skill is recognising which known technique fits a new problem, quickly, and explaining the trade-offs while you write the code.

  • Core: Common problem patterns

    Two pointers, sliding window, fast and slow pointers, BFS and DFS, top-k with a heap, backtracking and dynamic programming. Around fifteen patterns cover most interview problems, so practising by pattern works better than solving random questions.

  • Core: Breaking a problem down

    Restate the problem, list the constraints, write the brute-force solution, then improve it. Following these steps keeps you moving when the efficient approach is not obvious, and shows the interviewer how you think.

  • Core: Communicating while you code

    Interviewers grade how you reach the answer as well as the answer. Explain your approach, state the complexity, and test edge cases out loud.

  • Recommended: Deliberate practice

    Revisit problems you got wrong a week later. If you cannot work out the solution again, you remembered the answer rather than the technique.

  • Recommended: Edge cases and complexity

    Empty input, a single element, duplicates, integer overflow and the largest allowed input. State the time and space cost, and the cases that break a simple solution, before you are asked.

After this roadmap

  • SimulatorsSorting, heaps, B-trees, Dijkstra, dynamic programming and recursion, animated step by step in the browser.
  • Problem solving in the CodexWorked approaches to the problem patterns this roadmap lists.
  • CodexLonger study pages on languages, databases, operating systems and distributed systems.

Published Updated Change history