Detect cycle in a directed graph
If you can teach Detect cycle in a directed graph using bus routes, you know it. If you only know the heading, you don’t.
Detect cycle in a directed graph on the board: BFS queue / DFS stack. Then say what bus routes looks like after.
Without Detect cycle in a directed graph, a city map gets messy and bus routes is hard to trust.
Detect cycle in a directed graph shows up in a city map. Name bus routes, not “a real-world scenario”.
Don’t do this with Detect cycle in a directed graph: no visited set → infinite loop. Interviewers spot it in ten seconds.
After Detect cycle in a directed graph, Priya should still remember no visited set → infinite loop.
Viva for Detect cycle in a directed graph: what it is → BFS queue / DFS stack → the mistake (no visited set → infinite loop).
For Detect cycle in a directed graph: definition + a city map + one failure.