Problem 14.18 from Weiss's textbook:
A student needs to take a certain number of courses to graduate, and
these courses have prerequisites that must be followed. You may assume
that all courses are offered every semester, and that the student can take
an unlimited number of courses each semester. Using the methodologies
covered in chapter 14, write a program that computes a schedule that requires
the minimum number of semesters for a student to graduate, given a list
of courses and their prerequisites.
Each line of the input file (classes.dat) consists of a set of double-quote delimited strings, representing the names of classes. The first string on each line is a classname, followed by the names of the classes which are its prerequisites.
"cs1"
"cs2 Foundations" "cs1"
"cs3 Data Structures" "cs2 Foundations" "math11 Calculus I"
"cs52 Assembly Programming" "cs2 Foundations"
"math11 Calculus I"
"cs433 Operating Systems" "cs3 Data Structures" "math12 Calculus II"
"cs11 Computer Architecture"
"math12 Calculus II" "math11 Calculus I"
"cs11 Computer Architecture" "cs2 Foundations"
SAMPLE OUTPUT (be aware that there is more than one right answer for this input):
SEMESTER 1:
cs1
math11 Calculus I
SEMESTER 2:
cs2 Foundations
math12 Calculus II
SEMESTER 3:
cs11 Computer Architecture
cs52 Assembly Programming
cs3 Data Structures
SEMESTER 4:
cs433 Operating Systems
Oh my god! 4 more semesters still!!???