Solution Found!

Suppose a CS curriculum consists of n courses, all of them mandatory. The prerequisite

Chapter 3, Problem 3.16

(choose chapter or problem)

Get Unlimited Answers
QUESTION:

Suppose a CS curriculum consists of \(n\) courses, all of them mandatory. The prerequisite graph \(G\) has a node for each course, and an edge from course \(v\) to course \(w\) if and only if \(v\) is a prerequisite for \(w\). Find an algorithm that works directly with this graph representation, and computes the minimum number of semesters necessary to complete the curriculum (assume that a student can take any number of courses in one semester). The running time of your algorithm should be linear.

Questions & Answers

QUESTION:

Suppose a CS curriculum consists of \(n\) courses, all of them mandatory. The prerequisite graph \(G\) has a node for each course, and an edge from course \(v\) to course \(w\) if and only if \(v\) is a prerequisite for \(w\). Find an algorithm that works directly with this graph representation, and computes the minimum number of semesters necessary to complete the curriculum (assume that a student can take any number of courses in one semester). The running time of your algorithm should be linear.

ANSWER:

Step 1 of 4

Assume that in a graph a, there is a direction P. The courses in P are scheduled in separate semesters since each course in P is a prerequisite for the next course in P. As a result, the number of semesters is at least equal to the duration of P.

In graph G, let Q be the longest path. Q would have the same minimum number of semesters as Q. Let k be the length of Q. All courses must be scheduled in k semesters in order to design an optimal algorithm. In this case, a greedy approach can be used to design an optimal algorithm.   

Add to cart


Study Tools You Might Need

Not The Solution You Need? Search for Your Answer Here:

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back