Godisemo
Godisemo

Reputation: 1813

Find which ranges in a set that has a nonempty intersection with some specified range

Let us have a set of ranges r1, r2, ... rn. Then choose some other range R. What is the fastest (or at least a fast) algorithm to determine which of the ranges r1, r2, ... rn that has a nonempty intersection with R? Is there an optimal datastructure to store the set of ranges in?

Upvotes: 0

Views: 77

Answers (1)

Godisemo
Godisemo

Reputation: 1813

It looks like an interval tree is the way to go.

Upvotes: 1

Related Questions