Maximum interval overlaps using an interval tree [closed]

醉酒当歌 提交于 2019-12-09 16:41:26

问题


Here is an interesting question: Given a set of N intervals ([start, end]), use an interval tree to find the maximum number of overlapping intervals.

A similar question on StackOverflow provided an O(N) solution, but if we can pre-process the intervals into an interval tree, perhaps we can find the solution in logarithmic time.

In fact, an exercise problem in the "Introduction to Algorithms" book by Cormen, et al., suggests that this is possible by augmenting a red-black interval tree. Any ideas how this can be done?


回答1:


Some example to look. You may use interval tree for this. CGAL gives you a robust implementation for this. Another interesting example similar to your problem.




回答2:


you can find an interval tree based on an augmented AVL self balancing tree here: http://code.google.com/p/intervaltree/ . it shows you how it can be done. you can do the same to an red-black tree.



来源:https://stackoverflow.com/questions/3755378/maximum-interval-overlaps-using-an-interval-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!