Given a set of integer intervals SI = {I1,I2,...,In}, I need to find the smallest partition of SI such that all the intervals of a subset of the partition are intersecting.
That is find the smallest P = {Pi : Pi⊂SI } where Pi∩Pj=∅
and such that ∀Ia,Ib∊Pi, Ia∩Ib≠∅
For example :
Given, SI = {[0,7],[0,6],[1,2],[4,10],[5,10],[9,10]}
The output should be, P*={{[0,7],[0,6],[1,2]},{[4,10],[5,10],[9,10]}} where |P*|=2
What is the name of this problem in literature ? Can anyone hint an efficient optimal algorithm ?
My current solution is a greedy one where I iteratively find the maximum overlapping intervals (using a O(nlogn) time complexity subroutine). For the given example, this outputs a partition P={{[0,7],[0,6],[4,10],[5,10]},{[1,2]},{[9,10]}} of size 3.
Usually, you would begin by sorting the intervals by end point, which makes all of this fast and easy.