The best data structure that allows you to effectively stretch all ranges (min., Max.) So that the value> = min and the value <= max?

Imagine that I have a set of minimum values ​​and maximum values. I want the data structure, which, given the external value, to most effectively give me pairs (min, max) for which the value> = min, the value <= max.

If you know that the ranges do not overlap, I suppose you could just create a balanced binary search tree in min, and the first node that has (min, max) that is satisfied should be the only one, But if the ranges can overlap, is there a data structure that can allow you to do this efficiently?

+3
source share
4 answers

The task you are describing is also known as a " stabbing request ." This is well described in graphic programming textbooks, where this is a very topical issue.

In addition, a wikipedia page in segment trees can help. These trees are a data structure that is commonly used to solve this problem.

+2
source

- (min, max) , , mins , .

0

: .

x (x, y). (x, y) . node V Y Y, V.

([, ) = RangeX, RangeY), x min, <= x min > . V - node x min. , Y V , RangeX. Y, RangeY .

0
source

Source: https://habr.com/ru/post/1788211/


All Articles