Day 23 - Topological SortOverview

Day 23 — Topological Sort

This chapter is being written. Check back soon!

What you’ll learn here

  • What it means for a graph to be a DAG (Directed Acyclic Graph)
  • Kahn’s algorithm — repeatedly take a node with indegree 0, BFS-style
  • DFS post-order — recursive variant that’s a one-liner once DFS is set up
  • Real-world applications: build systems (make, npm), task scheduling, course prerequisites, spreadsheet recalculation

If there’s any ordering at all on your dependencies, topological sort is the algorithm that finds it — and refuses to lie when one doesn’t exist (cycle detection).