See the assignment turn-in page (last modified on 14 January 2006) for instructions on turning in your assignment.
Given a set S of intervals, an interval partition of S is a set of subsets { S1, S2, …, Sn } with the properties
Given a set S of n intervals, one simple way to form an interval partition of S is to put each interval in its own subset; the resulting partition has size n. Generally, however, it is better to have a partition's size be as small as possible.
Greedy scan is another way of creating interval partitions. Given an interval set S, greedy scan considers each interval in S (the scan) and puts every interval that fits in a subset (greedy):
greedy scan(S) create an empty partition P while S isn't empty create an empty subset S' for each interval i in S if i does not overlap any interval in S' remove i from S add i to S' add S' to P return P
If the input is incorrect, your program should print an informative error
message preceded by "!
" (that's bang-space) to std-err and exit
with no further processing.
partition-intervals
is available in the class assignment
directory /export/home/class/cs-503/a2
. Remember the purpose of this assignment is to
implement a correct solution, not to copy the behavior of my solution. If my
solution's wrong and you copy the incorrect behavior, you're going to lose
points.
You can use gen-intervals
, also available in the class assignment
directory, to generate intervals. When run, it writes an randomly generated
interval set to std-out. You can use it with your program like so:
Because$ ./gen-intervals | ./partition-intervals
gen-intervals
creates a new interval set each time it's run, you
might find it more convenient to save the intervals in a file to provide your
program with consistent input:
$ ./gen-intervals > intervals $ ./partition-intervals < intervals
This page last modified on 15 February 2006. |