Data structure similar to Dictionary, but with range?

user4157685

Given a binary tree, each of it's nodes contains an item with range, for instance, one, particular node may contain a range of ( 1 to 1.23456 ]

If the query element is less than or greater than the described range, it inspects the respective child. For example, it is 1.3

As follows, we will be looking over the right branch, performing 2 "if" checks to see if it fits in the range of the element.

Even though balanced Binary Search Tree (BST) is an elegant way of traversing quickly through a dataset, the amount of "if" checks grows significantly if there are more and more children. It becomes even more of a problem, when it has to be done several million times per second.

Is there an elegant way of storing objects such that given an element with a value (1.3 for example), its value can be simply fed into something as Dictionary? This would quickly retrieve the proper element to whose range this value fits or null if it fits none.

However, dictionary doesn't check against ranges, instead, it expects a single value. Therefore, is there a data structure which can provide an item if supplied key fits within the item's range?

Here a person has similar problem, however he finds out that the memory is wasted. He is being advised to BST approach, but is it the only solution?

Sorry if there is an evident answer, I may missed it.

Erti-Chris Eelmaa

Are you asking about interval trees? Interval trees allow you get all the elements on the interval x..y within O(logn) time. For C# implementation I have used the libary called IntervalTreeLib and it worked nicely.

In computer science, an interval tree is an ordered tree data structure to hold intervals. Specifically, 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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Building data structure for Dictionary

From Dev

Is a dictionary the right data structure for this?

From Dev

Python - webscraping; dictionary data structure

From Dev

Is dictionary the best data structure for this case?

From Dev

Python - webscraping; dictionary data structure

From Dev

Data Structure: Dictionary Like Tree

From Dev

AngularJS - similar page structure with different data

From Dev

Is there a data-structure similar to JSON in JAVA?

From Dev

Is there a data-structure similar to JSON in JAVA?

From Dev

Update data frame / table from data with similar structure

From Dev

Update data frame / table from data with similar structure

From Dev

Is there a better data structure than dictionary for key existence

From Dev

Object Oriented Nested Dictionary Data Structure

From Dev

Which data structure is most suitable to implement a Dictionary?

From Dev

python: data structure efficiency between list and dictionary

From Dev

Dictionary data structure + fast complexity methods

From Dev

Dictionary structure with data from multiple lists

From Dev

Data Structure that works similar to JList in java swings for using in java FX

From Dev

Should I make separate table for data with similar structure

From Dev

Is there a TreeSet data structure equivalent in C++ with similar functions

From Dev

Should I make separate table for data with similar structure

From Dev

C# Data Structure Similar to A Thread(Storing method calls)

From Dev

how to parse different type of xml data or similar to xml structure

From Dev

how to extract a range of data in my special data structure in python

From Dev

python similar keys in dictionary

From Dev

Best lookup data structure to store only the keys (Dictionary without value)

From Dev

What data structure in Scala is Python's nested dictionary or a csv?

From Dev

Contextual type 'AnyObject' cannot be used with dictionary literal - data structure not consistent

From Dev

Correct usage of custom data structure for Multi Key Dictionary

Related Related

  1. 1

    Building data structure for Dictionary

  2. 2

    Is a dictionary the right data structure for this?

  3. 3

    Python - webscraping; dictionary data structure

  4. 4

    Is dictionary the best data structure for this case?

  5. 5

    Python - webscraping; dictionary data structure

  6. 6

    Data Structure: Dictionary Like Tree

  7. 7

    AngularJS - similar page structure with different data

  8. 8

    Is there a data-structure similar to JSON in JAVA?

  9. 9

    Is there a data-structure similar to JSON in JAVA?

  10. 10

    Update data frame / table from data with similar structure

  11. 11

    Update data frame / table from data with similar structure

  12. 12

    Is there a better data structure than dictionary for key existence

  13. 13

    Object Oriented Nested Dictionary Data Structure

  14. 14

    Which data structure is most suitable to implement a Dictionary?

  15. 15

    python: data structure efficiency between list and dictionary

  16. 16

    Dictionary data structure + fast complexity methods

  17. 17

    Dictionary structure with data from multiple lists

  18. 18

    Data Structure that works similar to JList in java swings for using in java FX

  19. 19

    Should I make separate table for data with similar structure

  20. 20

    Is there a TreeSet data structure equivalent in C++ with similar functions

  21. 21

    Should I make separate table for data with similar structure

  22. 22

    C# Data Structure Similar to A Thread(Storing method calls)

  23. 23

    how to parse different type of xml data or similar to xml structure

  24. 24

    how to extract a range of data in my special data structure in python

  25. 25

    python similar keys in dictionary

  26. 26

    Best lookup data structure to store only the keys (Dictionary without value)

  27. 27

    What data structure in Scala is Python's nested dictionary or a csv?

  28. 28

    Contextual type 'AnyObject' cannot be used with dictionary literal - data structure not consistent

  29. 29

    Correct usage of custom data structure for Multi Key Dictionary

HotTag

Archive