Problem help (prerequesites problem from topcoder)
Posted: Mon Mar 28, 2005 9:34 pm
Hello,
can someone give me some tips and hints to solve this problem (I don't want no full code or full algorithm)?
This is a problem from top coder. Actually it's a subset of that problem since I just want some ideas and this is the part I have trouble with. The other parts include sorting. If someone is curious about the rest of the statement please say so.
Given a set of "classes" and their prerequesites, for example
Class10: Class01 Class02
Class02: Class01
Class01: (no pre requesite)
And given this the program must create a schedule, that is, an order of classes respecting some rules (if a class A is PR of another Z class, then class A must come before class Z).
To that example above the schedule would be:
result = { "Class01", "Class02", "Class10" }
Another example
Class101: XXX01 YYY02
XXX01: (no ...)
XXX02: (no ...)
Result = "XXX01" "XXX02" "Class101"
The can also be cases where we can't produce a result, as in example
Class01: Class02
Class02: Class01
In this case the program will return an empty list.
Ideas, hints ant tips are welcome
.
Thanks in advance.
can someone give me some tips and hints to solve this problem (I don't want no full code or full algorithm)?
This is a problem from top coder. Actually it's a subset of that problem since I just want some ideas and this is the part I have trouble with. The other parts include sorting. If someone is curious about the rest of the statement please say so.
Given a set of "classes" and their prerequesites, for example
Class10: Class01 Class02
Class02: Class01
Class01: (no pre requesite)
And given this the program must create a schedule, that is, an order of classes respecting some rules (if a class A is PR of another Z class, then class A must come before class Z).
To that example above the schedule would be:
result = { "Class01", "Class02", "Class10" }
Another example
Class101: XXX01 YYY02
XXX01: (no ...)
XXX02: (no ...)
Result = "XXX01" "XXX02" "Class101"
The can also be cases where we can't produce a result, as in example
Class01: Class02
Class02: Class01
In this case the program will return an empty list.
Ideas, hints ant tips are welcome

Thanks in advance.