Graph Theory37 sections · 1633 units
Open in Course

Lessons from Course Schedule II

What you learned

What we learned:

1.1. Prerequisite problems are graph problems. Each dependency [a,b][a, b] ("bb before aa") becomes a directed edge bab \to a.

2.2. Topological sort finds valid orderings. If we can process all nodes, we have a valid schedule.

3.3. Cycle detection is built-in. If Kahn's algorithm can't process all nodes, there's a cycle. Return empty.

4.4. In-degree tracks "remaining prerequisites." When in-degree hits 00, the course is ready to take.

Pattern recognition: Any problem asking "can you order X given dependencies?" or "find a valid sequence respecting constraints" is likely a topological sort problem.