Open In App

Exploring Range Trees

While learning data structures we come across various types of data structures ranging from data structures like arrays to slightly difficult data structures like graphs and their various subcategories. One of which is the type of data structure that we are going to discuss today “Range Trees”.

What are range queries and range trees?

Before moving on with the Range Trees let us first discuss the range queries that are addressed in a very efficient manner by the range trees.



Range Queries:

Range Trees:

An example of a 1-Dimensional range tree. Every node other than the leaf node stores the highest value in its left subtree.

In the above example the range queries can be addressed, since at each node the value of the next left subtree is either equal or less than and the values in the right sub-tree is greater than the node value. The complete illustration of range tree is given the Illustration of Range Tree section below.

Working of a Range Tree:

A range tree is made recursively. A BST(Binary Search Tree) on a dimension of points constitutes one level of a range tree and this is done until all the points are addressed which means the first level of the range tree is the BST of the first dimension of points and so on.



Each node of the tree has two information in it: 

To address a range query, recursive traversal of the tree is done. The interval of query is compared to the range of each node in the tree. If the  interval intersects the range of node, then the maximum value of the node’s range is reported and if this is not the case then the traversal is continued on next dimension of the query interval which is the child node.

Operations on Range Trees:

The various operations of the range trees are-

1. Construction of Range Trees:

2. Insertion in a Range Trees:

3. Deletion from Range Trees:

4. Range Query:

5. Range Minimum/Maximum Query:

6. Range Count Operation:

Illustration of Range Tree:

A Range tress is a balanced BST in which at any node, the left sub-tree will have the values less than or equal to the node value and in the right tree the value is greater than the node value and with this the tree is traversed and the range query is addressed

Example:

Illustration of Range Tree

Applications of Range Trees:

Limitation of Range Trees:

Conclusion:

The Range Trees are a very powerful and versatile data structure which can be used in handling multi-dimensional data queries in a very efficient manner which makes it an essential tool and with time these data structures are also evolving and for enhanced performance Fractional Cascading and Higher Dimensional Range Trees are also introduced. These type of data structures can help software developers to solve multi-dimensional, spatial and computational problems with ease.


Article Tags :