algorithm - Finding all the intervals that does not overlap with the point -
i have intervals of form (a1, b1), (a2, b2), ...., (an, bn)
.
support following operations
- adding new interval.
- deleting existing interval.
- given point, find intervals not overlap point.
intervals tree straightforward solution if want find intervals overlap point. case when want find non intersecting intervals?
have nodes in 2 trees simultaneously. tree holds them key ai
, tree b holds them key bi
.
insertion , deletion o(log n)
.
requirement 3, print nodes in b smallest biggest , stop when bi
still smaller point. same, backwards, in a.
example:
given (1,10), (5,18), (13,20)
, , point 12
.
interval(s) in ai
bigger 12
(13,20)
, , in b interval(s) smaller (1,10)
.
Comments
Post a Comment