taking school courses efficiently
Form a directed graph of dependencies, with an edge $x\to y$ if course $x$ is a prerequisite for course $y$.  Use Kahn's algorithm to topologically sort the graph.  In particular, in each semester, you take all courses with indegree 0 (i.e., all courses where you've satisfied all prerequisites), then delete those courses from the graph.

This assumes there is no limit on the number of courses you can take in each semester.  Under that condition, it will let you complete your degree in the minimum number of semesters, in an order that respects the prerequisites.

If there is a limit on the number of courses you can take in a semester, the problem is more challenging.    This algorithm will find an order you can take your courses to get your degree, in an order that respects the prerequisites, but it is not necessarily the minimal number of semesters.  If you're in that situation, the best solution may depend on the number of courses you have and whether this is a practical problem you want to solve in real life or a theoretical problem where you care about worst-case asymptotic running time.