Good data structure for finding date intervals including a given date

Jean-Daniel jeandaniel.browne at gmail.com
Sat May 12 10:18:07 EDT 2012


> Since you say "intervals" in plural here, I assume that they can overlap?

Yes,

For instance, there are the following intervals :
[[1, 10],
[4, 7],
[6, 15],
[11, 17]]

asking for the intervals including  5, the returned value should be

[[1, 10],
[4, 7]]

The idea here to make it fast is to have done some preprocessing at
insertion time, so that not all intervals are processed at query time.



On Sat, May 12, 2012 at 2:30 PM, Karl Knechtel <zahlman at gmail.com> wrote:
> On Sat, May 12, 2012 at 8:17 AM, Jean-Daniel
> <jeandaniel.browne at gmail.com> wrote:
>> I am looking for a fast way to find the intervals
>> containing a given date, without having to check all intervals (less
>> than O(n)).
>
> Since you say "intervals" in plural here, I assume that they can overlap?
>
> --
> ~Zahlman {:>
> --
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list