Phase 1: Try to schedule courses — discover the impossibility
Five Courses. Simple Prerequisites.
— Confession:I once spent twenty minutes manually trying to find a valid schedule for a set of courses before I realized the problem was asking whether one EXISTS — not asking me to FIND it. The courses had a circular dependency, and no amount of rearranging would fix it. The algorithm's job is to detect the impossibility, not to solve through it.
Course 0 requires Course 1 and Course 2. Course 1 requires Course 3. Course 2 requires both Course 3 and Course 4. These are directed prerequisites — an arrow from A to B means “B before A.” Tap courses in a valid order: you can only take a course after all its prerequisites.
FIG. 1 — FIVE COURSES, DIRECTED PREREQUISITES
Completed: 0/5 — tap in order
0
1
2
3
4
Tap each course when its prerequisites are done. Leaves (no prerequisites) can go first.