Skip to content

Data structures

Big picture: the cost of an algorithm depends on the structure it walks. Sorts and searches first, then trees and graphs, then the searches that need those structures.

Reading order

  1. Sort and search: comparison sorts, and searching a sorted collection.
  2. Recursion and dynamic programming: solving a problem from smaller versions of itself, and when to store the answers.
  3. Trees and graphs: binary trees, heaps, and graphs.
  4. BFS and DFS: the two walks over those structures.
  5. Balanced trees: AVL, red-black, and B-trees, so a search stays cheap.
  6. Shortest paths and ordering: topological sort and Dijkstra.