2 D-Range Tree
M.B.Chandak
[email protected]
www.mbchandak.com
Note: No voice or video sharing is permitted during Zoom meeting
All queries: please mail at [email protected]
• Unit-V
• Computational Geometry: One Dimensional Range Searching, Two
Dimensional Range Searching, Constructing a Priority Search Tree,
Searching a Priority Search Tree, Priority Range Trees, Quad-trees, k-D
Trees, Applications.
What we have discussed in previous class
• One dimensional range tree.
Dataset = [10, 3, 5, 12, 16, 55, 23, 67 ….]
We can construct a tree in the form of BST, which can provide solution
to queries like
Find values between: 12 and 50.
We have seen: some definitions also.
Part of sub tree is involved in search or some time complete sub tree is
involved in search.
Two dimensional Range Searching
Example data set
Name Age Salary
• There are two methods:
• 1. Unbalanced 2D range tree
Query: find age>x and salary>y • 2. Balanced 2D range tree.
Then 2D range search is suitable
Data is in the form of <x,y> tuple.
To optimise search, data should be
properly stored.
Example: Unbalanced 2D range tree
• (x1, y1) (x2, y2) (x3, y3) ……. (xn, yn)
• Similar to BST Select first value as Root
X1, Y1
• For storing next value: Decision is X, Y, alternate compare operation.
• Compare X1 and X2 and store: (X2, Y2) Either to left or right of (X1,
Y1) based on X1 > X2 or X1 < X2
X1, Y1
X1, Y1
X2, Y2 X2, Y2
Example: Unbalanced 2D range tree
• (4,9) (6,7) (2,9) (5,6) (6,3) (8,5) (9,2) (10,2) (5,9) ..
• Similar to BST Select first value as Root
4,9
• For storing next value: Decision is X, Y, alternate compare operation.
• Compare X1 and X2 and store: (X2, Y2) Either to left or right of (X1,
Y1) based on X1 > X2 or X1 < X2
4,9 4,9
4,9
6,7 2,9 6,7
2,9
Insert (5,6)
4,9
4,9
2,9 6,7
2,9 6,7
5,6
• First compare x1=4 with x4=5, Go Right
• Since location is not free: Compare y2=7 with y4=6 Go left
• If (6,3) is to be inserted. (4:6)Right
• Now compare: (7:3) Left
• Compare (5:6) Right [Insert as location is free]
Insert (6,3) Insert new value (1,7)
4,9
2,9 6,7
1,7 5,6
6,3
• If continued: the tree will be unbalanced 2D Range tree.
• It may not guarantee the search time. The data positioning can be more
precise, if tree is balanced. Refer .xls sheet