Data structure for quick time interval look up

后端 未结 4 1532
一整个雨季
一整个雨季 2020-12-02 17:31

I have a set of time intervals In = (an, bn). I need to run lots of look ups where I\'m given a time t and need to quickly return the intervals that conta

4条回答
  •  春和景丽
    2020-12-02 18:29

    Your problem is only one dimensional, so it's a bit simpler than the space partitioning problems found in most games. You could have just a simple BST and in each leaf remember list of intervals to the left fromt the leaf.

    if you had intervals A (0, 10) and B (5, 15), then the leaves of the tree would be (0 with empty list), (5 with A), (10 with A, B) and (15 with B).

提交回复
热议问题