# Interval scheduling; sort by ending times

You have $$n$$ events on your calendar, deﬁned as intervals with a start time $$s_i$$ and a ﬁnish time $$f_i$$. The events might overlap, and you want to attend all the events, so you are going to create $$k$$ clones of yourself to achieve this. You want to minimize the number of clones you need, $$k$$. A clone can attend a certain non-overlapping subset of events.

I am trying to solve the problem above. The solution in the pdf, sorts the starting times. However, I think and have proved (by showing that an optimal solution can go through a series of swaps so that it becomes the result of the wanted algorithm) that it can be done by sorting the ending times. Basically, the algorithm is:

1. Sort the ending times.
2. Pop the interval with the smallest ending time. If it can't be visited by any of the existing clones, then make a new clone. Otherwise, choose the clone with the largest ending time such that the interval can still be taken by that clone.

I am pretty convinced that this works, however, I am not able to find any reference on the internet about this algorithm.

Sorting by $$f_i$$ is optimal in another problem of finding the maximum number of events one can take but not optimal by $$s_i$$ so it is intuitive to extend the reasoning to this problem. Is this conceptual approach correct?

• What is your question?
– orlp
Commented Feb 20 at 12:20
• @orlp I am looking for a reference or verification that it is valid. Commented Feb 20 at 12:23
• That is still not a question. A question ends with a question mark, e.g. "Is this correct?". Please edit your post to include a question so people can answer it.
– orlp
Commented Feb 20 at 12:25
• Please consult cs.stackexchange.com/q/59964/755 and follow the guidance there.
– D.W.
Commented Feb 20 at 17:58
• We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher.
– D.W.
Commented Feb 20 at 17:58