Notes 01
Notes 01
Roberto Tamassia
Computational Geometry Sem. II, 1992–1993
1 Introduction
This class cover three areas. The first area was an introduction to dynamic algorithms. The
second area was a review of data structures used frequently in Computational Geometry. The
third area was “one-dimensional range searching” and “two-dimensional range-searching”.
1
3.1 Dynamic Dictionaries
A dynamic dictionary, S, can be modeled as a dynamically evolving subset of a totally
ordered universe. An example of a totally ordered universe is a set of integers.
Two query operations that must be provided are search and locate.
Examples:
Search(q): Is q in S?
Locate(q): find largest x ∈ S such that x ≤ q
Four update operations that must be provided are insert, delete, split, and splice.
• Insert(x, S).
This operation inserts element x into dictionary S.
• Delete(x, S).
This operation deletes element x, if it exists, from dictionary S.
0 00 0 00
• Split(S, x; S , S ), where y ∈ S ⇔ y ≤ x, and y ∈ S ⇔ y > x.
0 00
This operation creates two dictionaries: S and S . Each dictionary is a subset of
0 S 00 0
dictionary S. S S ≡ S. S contains all the elements of S that have a value less than
00
or equal to x and dictionary S contains all the elements of S that are more than x.
0 00 0 0 00 00 0
• Splice(S ,S ; S), where x ∈ S and x ∈ S ⇔ x ≤ x00 .
This operation produces a new dictionary S. Dictionary S is a union of the elements
0 00
of dictionaries S and S .
In the following sections, specializations of the generic Binary Search Tree are used to
implemement the Dynamic Dictionary. All variations discussed have the following two prop-
erties: (1) nodes of the the Binary Search Tree represent elements of the Dynamic Dictionary
and (2) an inorder visit of the Binary Search Tree visits the nodes of the elements of Dynamic
Dictionary in sorted order.
2
figure=split.ps,height=3in
• A balanced search tree for n elements uses space O(n) and height O(log n)
• Balanced search trees are often augmented with secondary structures stored at the
internal nodes.
• A variation of red-black trees (equivalent to level linked 2-3-4 trees) has the following
additional properties:
3
3.4 Properties of BB[α] Trees
Consider a BB[α] tree augmented with secondary structures. Let f (l) be the time to update
teh secondary data structures after a rotation, where l is the number of leaves in the sub-
tree involved in the rotation. The amortized rebalancing time of an update operation in a
sequence of insertions and deletions is
4 Range Searching
Range Searching is given a set P points in a d-dimensional space, Euclideand , answer the
“Range Query”: Report the points of P contained in an orthogonal query r. “The choice of
search domain is frequently referred to as orthogonal query, possibly because the hyperplanes
bounding the hyperrectangle are each orthogonal to a coordinate axis.”[6] An example of a
two-dimensional range query is shown in Figure 4.
In general:
r = (a1 , b1 ) × (a2 , b2 ) × . . . × (ad , bd )
If d = 1 then the query range r is an interval on the line. If d = 2 the the query range r
is a rectangle with sides parallel to the axes.
Variations to the “range query” are (1) count the points in query range r and (2) if points
have associated weights, compute the total weight of points in r.
One-Dimensional Range Searching
See Figure 4 for example.
• use a balanced search tree T with internal nodes associated with the points of P
4
Exercises from Class
Queries can be performed in O(log n + k) without using threads. One could walk
the path from the root to µ0 in O(log n) time. As the walk was performed all nodes less then
µ0 could be spliced out of the tree. A similar treatement for µ00 , but this time you splice out
nodes greater than µ00 . Then the answer can be obtained by a pre-order walk of the tree,
enumerating the nodes as you go, will cost in time complexity O(k). The total of all three
operations being O(2 log n + k) which is equivalent to O(log n + k).
1-D range counting queries can be performed in O(log n) time. This can be
accomplished by keeping at each node the number of children it has. As you perform the
two O(log n) walks to find µ0 and µ00 you can subtract off the number of nodes not in the
answer.
Assuming that the points have weights, you can find in time O(log n) the
heaviest point in the query range. The two paths from the root to µ0 and µ00 can be
found in O(log n) time. Each node can store the heaviest node in its sub-tree. A traversal
from the path from µ0 to the root can calculate new heaviest nodes eliminating the nodes
not found in the answer to the query. A similar operation can be performed for µ 00 , the root
node will then contain the heaviest node for the answer to the query.
The space needed to n points in the one-dimensional ranage tree is O(n log n)
• the union of their point-sets is the set of oints in the range (x0 , x00 )
5
1. find the alocation nodes of (x0 , x00 )
Procedure Find(µ)
if x0 ≤ min(µ) and x00 ≥ max(µ)
then mark µ as an allocation node
else if µ is not a leaf then
if x0 ≤ max(left(µ))
then Find(left(µ))
if x00 ≥ min(right(µ))
then Find(right(µ))
Insertion time is O(log 2 n). There may be O(log n) rotations, each rotation may take
O(log n) to insert or delete an element form the point-set data structure associated with
each node. Similarly for deletions.
The secondary data structure associated with each node µ is a data structure for 1-D
range searching by y-coordinate in the set p(µ). This data structure can be either a 1-D
range tree or a balanced tree.
6
4.2.1 Two-dimensional Range Queries with the 2-D Range-Tree
See Figure 4.2.1. Query algorithm for range r = (x0 , x00 ) × (y 0 , y 00 )
• for each allocation node µ perform a 1-D range query for range (y 0 , y 00 ) in the secondary
structure of µ
When performing a rotation, we rebuild from scratch the secondary data structure of the
node that becomes the child (ther seems to be nothing better to do).
The cost of a rotation at a node µ is O(|P (µ|) = O(# leaves in subtree ofµ). By realizing
T as a BB[α]tree, the amortized rebalancing time is O(log n).
The total insertion time is dominated by the for-loop and is O(log 2 n) amortized.
Similar considerations hold for deletion.
7
4.2.5 Summary of Two-Dimensioanl Range Tree
• Two-level tree structure (RR-tree)
References
[1] Y. Chiang and R. Tamassia, “Dynamic Algorithms in Computational Geometry,” Pro-
ceedings of the IEEE, Vol 80, No. 9, Sept. 92 , 1412 – 1417, 1992.
[2] T. Cormen, C. Leiserson, and R. Rivest, “Introduction of Algorithms,” MIT Press and
McGraw-Hill, 1990.
[3] L.R. Guidbas and R. Sedgewick, “A dichromatic framework for balanced trees,” FOCS
1978.
[4] S. Huddleston and K. Mehlhorm, “A New Data Structure for Representing Sorted Lists,”
Acta Informatica 17, 157-184, 1982.
[5] N. Blum and K. Mehlhorn, “On the Average Number of Rebalancing Operations in
Weight-Balanced Trees,” Theoretical Computer Science 11, 303-320, 1980.