Questions tagged [interval-tree]

Interval-tree allows one to efficiently find all intervals that overlap with any given interval or point

In computer science, an interval tree is an ordered tree data structure to hold intervals.

It allows one to efficiently find all intervals that overlap with any given interval or point. It is often used for windowing queries, for instance, to find all roads on a computerized map inside a rectangular viewport, or to find all visible elements inside a three-dimensional scene. A similar data structure is the segment tree.

Queries require O(log n + m) time, with n being the total number of intervals and m being the number of reported results. Construction requires O(n log n) time, and storage requires O(n) space.

78 questions
3
votes
1 answer

IntervalTree in Guava

I am working with Guava's Range class for processing intervals. I wanted to know if it is possible to find the closest interval from a set of intervals to a given point/interval by using some of the Guava's collection containers ? I tried searching…
user1998031
  • 127
  • 2
  • 7
2
votes
1 answer

Determine how many time intervals intersect with every given time interval (R)

I am working with these data on R. These are the first six rows —without counting the first column, which the write.csv function always adds—: > head(my_data) client_id contract_id contract_start contract_end inter_complex 1 1 …
Werther
  • 133
  • 7
2
votes
1 answer

Time complexity analysis for interval tree

The interval tree I'm currently learning has the following data structures for each node: key: the median of endpoints of all the intervals left, right: pointing to left and right subtrees intervals: a list of intervals containing the intervals who…
Patrick
  • 555
  • 1
  • 6
  • 25
2
votes
0 answers

Given a list of ranges how can we find if the given value exist in that list of ranges in node js

I have aset of ip ranges and i need to find if the ip given by the user exists between the given list of ip ranges . This is in continuation to this question How to check if a given ip falls between a given ip range using node js Jonas helped me…
INFOSYS
  • 1,465
  • 9
  • 23
  • 50
2
votes
1 answer

Given an interval, Find all intervals In a list of Intervals

Let say I have a list of ranges like this [[1,3], [2,5], [4,6], [8,10], [12,15], [13,17]] Now I want to find a range say [3,11] falls in. My algorithm should give me all the ranges this range falls to. For example the output for this should…
Muthu Rg
  • 632
  • 1
  • 6
  • 18
2
votes
1 answer

Update and check if the substring containing brackets is correct

The problem is: Given the string with length of n, and m queries. Each query is one of two cases: Change the i-th character oppositely Check if the substring from u-th character to v-th character is the correct brackets expression or not. If yes,…
2
votes
2 answers

Practical Applications of Interval Tree

I have googled about this topic a bit and found this on http://www.geeksforgeeks.org/ Interval tree is mainly a geometric data structure and often used for windowing queries, for instance, to find all roads on a computerized map inside a…
Asiful Nobel
  • 323
  • 4
  • 14
2
votes
1 answer

Optimization of Rectangle-based Point Search

I have a set of rooms and passages that I can convert into Rectangles (x,y,width,height) or a list of Points (x,y). Room and Passage both extend the Pointable interface. The getPoints() method is implemented for the Room class as public Set
JohnAMeyer
  • 51
  • 7
2
votes
1 answer

interval map in C++

I need to map some intervals (actually these are intervals of addresses) to object ids. I tried to use boost's interval_map, the example looks very pretty, it easily enumerates all intervals like: while(it != party.end()) { …
2
votes
1 answer

Red-Black Tree Delete Fixup in CLRS Second Edition, in Clojure

I am implementing red-black tree deletion for interval trees following CLRS 2nd edition, fourth printing, pg 288-9. Summary of bug: RB-Delete-Fixup If x and w are the sentinel nodes, which is a possible consequence of RB-Delete, then the…
David Williams
  • 8,388
  • 23
  • 83
  • 171
2
votes
2 answers

find intervals not in tree

I have a bunch of (date)intervals which might overlap. The intervals come from different sources. I want to 'flatten' this 'timeline' and then find all intervals where no interval was. If you look at:…
Jeroen
  • 1,638
  • 3
  • 23
  • 48
2
votes
1 answer

Range tree construction

Let us consider the following picture this is a so called range tree. I don't understand one thing, it looks similar to a binary search tree, so if we are inserting elements, we can use the same procedure as during binary search tree insertion.…
1
vote
1 answer

Java implementation of 2 dimensional interval tree

I need a 2 dimensional interval tree for storing rectangular regions in a canvas. I need to identify the regions which contain the point clicked or the regions overlapping with a rectangular selection. Is there any standard implementation of 2…
Nullpoet
  • 10,949
  • 20
  • 48
  • 65
1
vote
1 answer

2D interval tree using 1D ones

I'm using the C# interval tree collection class class from here http://intervaltree.codeplex.com/SourceControl/list/changesets -> right hand side -> download. I need to get intervals from the collection that overlap given ones. This seems easy with…
alan2here
  • 3,223
  • 6
  • 37
  • 62
1
vote
2 answers

Listing all intervals that overlap interval i in O(min(n, k lg n)) where k is the number of overlapping intervals

This question is exercise 14.3-4 in Introduction to Algorithms, Second Edition. 14.3-4: Given an interval tree T and an interval i, describe how all intervals in T that overlap i can be listed in O(min(n, k lg n)) time, where k is the number of…