Circular Interval Scheduling
Textbook Exercise 17 in Chapter 4. In your answer, write:
- the pseudocode of an executable algorithm
- the analysis of the running time complexity
- proof of the optimality of the algorithm
Your algorithm, CircIntvlSched, can call IntvlSched shown below if and as needed. Consider the implementation of IntvlSched that has the running time complexity O(n logn). The proof of optimality is trivial from the optimality of IntvlSched; consider the optimality of IntvlSched already proven.
Pseudocode
See Figure 2 below(may be on another page). Created using the LaTeX packages algorithm, algpseudocode, and amsmath.
Time Complexity
Letβs let be a number of jobs.
For each anchor we have (with choices), we test with job , this is as the overlap tests are only
Mapping the compatibility list is .
Calling IntvlSched
on LinearList has worst case possibility of , and we know that IntvlShed
is .
Given that every anchor iteration is , and since we repeat for n anchors this is .
Space complexity is overall, for the linear list.
Proof of Optimality
Lets say OP is the optimal set for mutually non-overlapping jobs on this circular schedule. If we assume then algorithm returns and it is guaranteed correct.
For alternative case, we will consider when . Using construction:
- remove all other jobs that overlap on (only those that can be scheduled with remain)
- make a cut on the circular schedule, , then map remaining jobs into the linear 24 hour window. We cut at the end of , so no remaining jobs are on the cut.
- now, our optimal schedule (without a) has a mapping to a set of linear intervals with no overlap.
Given that IntvlSched
is optimal for linear scheduling, we know that it returns a max size set for all sets of compatible jobs that do not overlap over .
This means that the return set on this anchor is at least , meaning the algorithm will find a schedule with a size that is at least the size of . And given that is optimal, so is the algorithm schedule.
Interval Partitioning: Greedy Strategies
Consider the IntvlPart greedy algorithm with the earliest start time first strategy we discussed in class (pseudocode shown below), and consider the following three alternative greedy strategies:
- Earliest finish time first β consider lectures in ascending order of finish time f(j)
- Shortest interval first β consider lectures in ascending order of interval length, f(j) β s(j)
- Fewest conflicts first β for each lecture, count the number of conflicting lectures; then, consider lectures in ascending order of the number of conflicts.
For each of these three greedy strategies, either prove or disprove if it is an optimal greedy strategy. If you want to prove it, use a proof technique of your choice (e.g., induction, contradiction, construction) and name the used proof technique at the beginning of the proof. If you want to disprove it, it suffices to provide a counterexample and state what the greedy strategy finds as a solution and what a true optimal solution is. For simplicity, your counterexample should contain as few lectures as you can find. Hint: remember we used a structural bound called βdepthβ, which denotes the largest number of intervals overlapping at any time.
Earliest Finish time First
Seek to disprove using counterexample:
First, we look at the given lectures , in this case, :
The depth is 2 given max overlapping intervals, meaning that any optimal choice will use 2.
We then order by finish time, so
Then run greedy partitioning:
This finish time order uses 3 rooms and not 2, so this is not optimal.
Shortest Interval First
Seek to disprove using counterexample:
Given two Lectures and , length 2 and 1 respectively, and their depth being 1 so optimal path needs 1
room.
Then we order by interval length, so then .
Run greedy partitioning:
This yields 2 rooms with greedy partitioning, when the optimal is 1, and is thus not optimal.
Fewest Conflicts First
Seek to disprove using counterexample:
Given :
And the conflicts that come with it:
Resulting in a depth of 2 as B/A overlap. Optimal is 2 rooms.
Run greedy partitioning:
This yields 3 rooms when the optimal is 2, therefore fewest conflicts is not an optimal algorithm.