Académique Documents
Professionnel Documents
Culture Documents
334
Multidimensional
ON COMPUTERS, VOL.
c-33, NO. 4,
APRIL
1984
Height-Balanced Trees
VIJAY K. VAISHNAVI
Abstract -A new multidimensional balanced tree structure is multidimensional data. Inverted files are such "multipresented for the efficient management of multidimensional data. dimensional" data structures. These are extensions of data
It is shown that the data structure can be used to manage a set of structures originally designed for one-dimensional data and
n k-dimensional records or data items such that the records
can be searched or updated in O(log2 n) + k time, which is opti- do not provide an efficient solution to the problem. Lum [20]
mal. The data structure is a multidimensional generalization of introduces the technique of combined indexes, which conthe height-balanced trees and retains much of their simplicity and catenates several attributes into a single key. This technique,
efficiency. The insertion algorithm, in particular, retains a very however, needs excessive storage and update time for it to be
important property of the height-balanced trees: an insertion of a really useful. Grid file [23] is very efficient for searching a
record results in the application of a restructuring operation at
record, but its storage and update time need to be investigated.
most once.
I. INTRODUCTION
335
where u is the root of the tree storing a key, say, s of dimension k; TI, Te, and Th are called, respectively, the LOSON-,
the EQSON-, and the HISON-subtrees of u; 1 is the left direct
son, e is the EQSON, and h is the right direct son, of u; TF,
the LOSON-subtree, is a k-dimensional search tree for all the
records in F whose keys of dimension k are less than s; Te,
the EQSON-subtree, is a (k - 1)-dimensional search tree
for the (k - 1)-dimensional projection of records in F obtained by omitting s, their identical key of dimension k; Th,
the HISON-subtree, is a k-dimensional search tree for all the
records in F whose keys of dimension k are greater than s.
Example 2.1: Fig. 1 shows a two-dimensional search tree
for the 2-file F = {(1, a), (1, b), (2, a), (3, a), (3, b), (4, a),
3
a
Fyt)1
U) 1
2
Nb
(4)3
x
1
a
0
Ic
Lb
MC1
Fig. 1.
(4, b), (5, a), (5, b), (5, c), (5, d)}. Note that in the record
(3,b), b is a key of dimension 1 and 3 is a key of
336
R
P
h1
R
P
~~~~p
Q)
(a)
(b)
(c)
Fig. 2.
following modifications:
a) The definition of the direct support of an n.e. pair in the
tree is extended to an "n.e. quadruple" (of nodes). An n.e.
quadruple at height h is constituted by four nonexisting left
(right) direct sons of a node P at heights h, h + 1, h + 2, and
h + 3. Such a quadruple is directly supported if the height of
the EQSON-subtree of P is greater than or equal to h.
b) The structure of the tree is constrained by imposing
the requirement that every n.e. quadruple must be directly
supported.
It is easy to see that an almost kHB-tree can alternatively
be simply defined as a k-dimensional search tree such that if
T,, Te, and Th are the LOSON-, EQSON-, and HISON-subtrees
of a node, respectively, then either Te is the tallest subtree or the
difference between the heights of any two of its three subtrees
is at most 3.
Lemma 2.1: Given a kHB-tree T of height h, storing n
records, it can be transformed into an akHB-tree T1 of the
same height storing n or less records.
Proof: See Appendix A (Lemma A. 1).
Let N(h, k) be the minimum number of records stored in an
akHB-tree of height h.
Lemma 2.2: N(h,k) = N(h - k + 1,1), h k.
Proof: See Appendix B (Lemma B.3).
Lemma 2.3: The height of an akHB-tree storing n records
is at most 2.25 10g2(n + 2) + k - 2.112.
Proof: N(h,k) = N(h - k + 1, 1), h k (Lemma
2.2). Therefore, h - k + 1 2.25 log2(N(h,k) + 2) 1.112 (see Luccio and Pagli [19]). Thus, h < 2.25 log2(n +
2) + k - 2.112.
Theorem 2.1: The height of a kHB-tree storing n records
iS O(log2 n) + k.
Proof: Follows from Lemmas 2.1 and 2.3.
-
337
[*]
B (b) h
A La) h or
h-l(*)
or
must be supported because f and f have the same adjoining [r]
1
ch-1
[=1 or A
[-1
EQSON-subtrees, which is a contradiction.
A node P in T is said to have a double-sided structure
5
violation at height h if P1, a left direct/indirect son of P, has
4h-3
3
a right strong structure violation at height h, and P2, a right
direct/indirect son of P, has a left strong structure violation
1
3
4h-2
h-2
at height h. The associated n.e. pairs of the strong structure
(a)
(b)
violations to P1 and P2 are said to be the associated n.e. pairs
Fig. 3.
of the double-sided structure violation.
In case of the height-balanced trees, the restructuring operations used in the insertion and the deletion algorithms are the
"rotation" and the "double rotation." These very operations
[*1
along with a variation of the double rotation are useful for the
B b h~(*)
insertion and the deletion algorithms of the kHB-trees. We
will call them simply as the restructuring operations. In the
following we will describe these operations (omitting their
symmetric variants) and establish their "correctness." A re7
A a 0-2
Cc
h-2
structuring operation applied at the root of a subtree to correct
4h- 3
a structure violation is said to be correct if the restructured
6 - 7
2
subtree does not contain any unsupported n.e. pair; its height
may, however, decrease by one. In the following, a "*" in
7
5
3
1
square brackets against a node indicates that there is a struc- <h-3
ture violation to the node. A "*" in parentheses against the
height of a node, similarly, indicates that the height of the
node has just changed.
(a)
(b)
Let T be a kHB-tree with an (h, i)-node (B in Fig. 3, C in
4.
Fig.
Figs. 4 and 5) having a right structure violation at height
h - 2. Let its associated n.e. pair be the only n.e. pair in the
tree that may possibly be unsupported. In such a situation, the
rotation or the double rotation (type A or B) is applied at the
[*]
node. The rotation is applied when the HB-condition of A,
h
Cc
A (a) h-l(*)
the left direct son of the node, is ""=r," or "6-" (Fig. 3).
[+1
The double rotation (type A or B) is applied when the HB^
7
A a h-1
h-2
condition of A is "+" (Figs. 4 and 5). The type A double
rotation (Fig. 4) is applied when the structure violation (to C)
h-2
B
1
3
is special or the height of the HISON-subtree of B is h - 3,
<h-3
and the type B double rotation (Fig. 5) is applied when this
is not the case.
5
3
5
Fig. 3 and its symmetric variant describe the rotation
(b)
operation. The restructured subtree is an iHB-tree with no
(a)
Fig. 5.
change in its height or with decrease in its height by 1
(Fig. 3).
A structure violation will result (to P) only in the following
Figs. 4 and 5 and their symmetric variants describe the
type A and the type B double rotation operations, re- situations:
a) The decrease in the height of the LOSON- (respectively,
spectively. The restructured subtree in each case is an
HISON-) subtree of P by 1 to, say, height h - 1, creates a new
iHB-tree with decrease in its height by 1.
Some of the above restructuring operations may decrease n.e. pair, say,f of left (respectively, right) direct sons at height
the height of a node by 1 to h - 1. The decrease in height h, which is not directly supported. Note that, if the height of P
may propagate all the way to the root without causing any is more than h + 2, then, by Lemma 3. l,f must be supported.
structure violation. On the other hand, the propagation of the
b) The decrease in the height of the EQSON-subtree of P
height decrease may stop at a node P. As a result, there may by I to height, say, h - 1, makes an n.e. pair at height h or
or may not be a structure violation or a double-sided structure more lose its support or direct support.
A double structure violation will result to P only if the
violation to P.
338
correct.
Proof: Unless otherwise stated, we have the following
in Fig. 5(b).
The type B double rotation is applied only when the structure violation to C [Fig. 5(a)] is not special and height of the
subtree 5 is not h - 3. Thus, the height of C is h - 3 or less.
The height of B [Fig. 5(a)] is h - 2 and therefore the height
of the subtree 3 or that of 4 must be h - 3. Hence, the height
of B is h - 2, and that of A is h - 1.
The only n.e. pairs that may get created are those between
B and C (in case the height of C is h - 5 or less). All other
n.e. pairs in the subtree continue to be supported by at least
one of their respective adjoining EQSON-subtrees. Let us
therefore examine the n.e. pairs between B and C.
Let the height of C be h - 5 or less. This implies that the
heights of the subtrees 5, 6, and 7 are h - 6 or less. In
Fig. 5(a), the n.e. pair of right direct sons of B at height
h - 4 must be supported. Thus, the height of the subtree 4 or
that of 6 must be h - 4 or more. Height of 6 cannot be h - 4
or more because it contradicts the assumption that the height
of C is h - 5 or less. Therefore, the height of 4 must be
h - 4 or more. But then, 4 will support any n.e. pair between
B and C.
The restructuring operations lead to the following restructuring algorithm for removing a structure violation or a
double-sided structure at height h to a node P in a kHB-tree
of height H.
Algorithm R:
1) There is a possibly strong structure violation at
height h, to P:
Apply an appropriate restructuring operation;
if the restructured subtree does not decrease in height
then STOP
else apply the algorithm recursively;
2) The height of a subtree decreases in height by 1:
if the decrease in height causes a structure violation or
a double-sided structure violation to a higher node
then apply the algorithm recursively
339
c-33,
340
.I1
fi
Ja2
(3
Ka
Ic
Lb
01b
4, APRIL 1984
NO.
l1
Pal
Fig. 6.
4.
T P.-
I\
2
h-1
h-i
Fig. 7.
T P.-
T -
P ()h
h-i
2
h-2
h-i
10
Fig. 8.
Tp:
T -
P-
P (
1 h-i
8
10
11
h-2
12
(a)
T -:
7:
13:
R
t+ 1.
2.1.3.1. Ht. (6) t [see Fig. 9(a)]. This implies that the
height of S will not decrease if 5 is replaced by an empty tree.
Transformation: 8 = flipped1 (13), 9 = 4, 10= 4,
'The tree flipped(1) is the tree T with its LOSON- and HISON-subtrees
exchanged.
14
1.5
(b)
341
T P.-:
TP
subtree of P which is unsupported, or indirectly supported by
P
9 or the EQSON-subtree of U.
P
h
2.1.3.2. Ht. (6) < t [see Fig. 9(a)].
M
)
h-i
7
M
-i
13
4
Transformation: 8 = flipped (13), 9 = 6, 10 = 4,
/mh-3
11 = 2, 12 = 4, where 13 [see Fig. 9(b)] is 7 transformed
as: 14 = 4), 15 = 4.
1
2
8
9
The height of 5 is t or less, and that of 6 is less than t.
Sit
Sif
Therefore, the height of S in 13 [Fig. 9(b)] will continue to
be the same as in 7. Note that the height of S in 7 cannot be
3
4
5
10
11
12
more than t + 2 because otherwise there is an unsupported
Fig. 10.
n.e. pair in the tree. Thus, if in Tp, 7 is replaced by 13 and 4
P
is replaced by 6, then there cannot be an n.e. pair in the
Tp.
Tp '
tree rooted at R which is either unsupported or indirectly
P
h
supported by 6. Therefore, in Tp the difference between the
LOSON- and the HISON-subtrees of P is at most 2, and there
h- or
1
Q
6
7 Q t
h-3
h-2
h-1
is not an n.e. pair in the trees rooted at the left and the right
3
5
direct sons of P which is not supported or which is indirectly
8
0
>h-4
supported by 9 or the EQSON-subtree of U.
Fig. 1 1.
2.2. Ht. (EQSON-subtree of P) = m h - 3. Assume
that the height of the LOSON-subtree of P is h - 1. TransTp formations described in I and II below are applied one after
p
P
h
the other. The transformation described in I results in Tp and
that in II results in Tp.
1
11R
10
>h-4
h-i
h-1
I. Let SI be the left son of P such that its height has the
smallest value larger than or equal to m + 1 (see Fig. 10).
1'5
16
I. 1. Ht. (4) >, m.
S1
Transformation: 8 = 1, 9 = 2, 10 = 4, 11 = 4,
12 4, 13 = 6, 14 7.
12
13
14
1.2. Ht. (4) < m.
Transformation: 8 1, 9 = 2, 10= 4, 11 = 6,
5
12 = 4, 13 = 4, 14 = 7.
Fig. 12.
As a result of the transformation M satisfies Property A
while P continues to satisfy Property A. There may, howProof: By induction on h.
ever, be n.e. pairs in the HISON-subtree of P which are
Basis h = 2 or 3.
unsupported because they are no more indirectly supported
a) N(2, 2) = 1 = N(1, 1)
by the EQSON-subtree of P.
N(3, 2) = 2 = N(2, 1) [see Fig. 13(a)].
11. 1. Ht. (4) > h - 4 (see Fig. 11). Note that height of
b) N(2,2) = 1 N(1,2) + N(-2,2) + 1
Q will be h - 1 or h - 2 because P satisfies Property A.
because N(h, 2) = 0 if h < 2.
Transformation: 6 = 1, 7 = 2, 8 = 4, 9 = 4,
N(3,2) = 2 = N(2;2) + N(-1,2) + 1.
10 = 4).
Induction hypothesis: For 2 h s,
11.2. Ht. (4) = t, t < h - 4 (see Fig. 12). Let S be the
a) N(h, 2) = N(h - 1, 1),
right son of Q such that its height has the smallest value larger
b) N(h, 2) = N(h - 1, 2) + N(h - 4, 2). + 1.
than or equal to t + 1. Let the height of Q be r. The height
Induction step: To prove that the result is true for
of R will obviously be r - 1 or r - 2.
h = s + 1, s : 3. We will now prove this:
II.2. 1. Ht. (6) :,> t.
a) N(4, 2) = min{N(3, 1), N(3, 2) + 1}
Transformation: 10 = 1, 11 = 4, 12 = 4), 13 = 6,
[see Fig. 13(b)]
14 = 7, 15 = 8, 16 = 9.
N(3,2) + I = N(2, 1) + 1
11.2.2. Ht. (6) < t.
[by induction hypothesis a)]
Transformation: 10 = 1, 11 = 6, 12 = 4, 13 = 4,
= N(3, 1)
14 = 7, 15 = 8, 16 - 9.
+
N(s 1,2) = min{N(s, 1), N(s, 2) + N(s -3,1),
It is easy to see that Tp satisfies the desired properties.
N(s,2) + N(s - 3,2) + 1}, s 4.
[see Fig. 13(b)]
APPENDIX B
N(s,2) + N(s - 3,1)
Let N(h, k) be the minimum number of records stored in an
=N(s - 1, 1) + N(s - 3, 1)
akHB-tree of height h, k > 1.
[by induction hypothesis a)]
Lemma B .]: For h 2,
=N(s - 1, 1) + N(s - 4, 1)
+ 1 + N(s - 7, 1)
a) N(h, 2) = N(h - 1, 1),
=
+
+
1.
b) N(h, 2) N(h 1, 2) N(h 4, 2)
=N(s, 1) + N(s - 7, 1)
h
'> AXh
3EEE
342
P) 3
Yh
0
(b)
t+2
t+2
c-33,
NO.
4,
APRIL
1984
(a)
.0
(C)
(d)
Fig. 13.
N(s, 2) + N(s - 3, 2) + 1
= N(s - 1, 1) + N(s - 4, 1) + 1
[by induction hypothesis a)]
= N(s, 1)
Thus, N(s + 1,2) = N(s,1)
b) N(s,2) + N(s - 3,2) + 1
- N(s - 1, 1) + N(s - 4 1) + 1
[by induction hypothesis a)]
= N(s, 1)
N(s + 1, 2) = N(s, 1) (as proved above).
Thus, N(s + 1, 2) = N(s, 2) + N(s - 3, 2) + 1.
Lemma B.2: For i 2, h i,
a) N(h, i) = N(h - l, i - 1),
b) N(h, i) = N(h - 1, i) + N(h - 4,i) + 1.
Proof: by induction on i.
Basis i = 2, proved by Lemma B. 1.
Induction hypothesis: For 2 i t,
a) N(h,i) = N(h - 1,i - 1),
b) N(h,i) = N(h - 1,i) + N(h - 4,i) + 1.
Induction step: To prove that the result is true for i =
t + 1, t 2.
Proof: by induction on h.
Basis h = t + 1, or h = t + 2.
h=t+ 1
N(t + 1, t + 1) = N(t, t) = 1,
N(t + 1,t + 1) = 1
-N(t,t + 1) + N(t - 3,t + 1) + 1
h= t+2
N(t + 2, t + 1) = min{N(t + 1, t),
N(t + 1,t + 1) + 1}
[see Fig. 13(c)]
N(t+ 1,t+ 1)+ 1'= 2
N(t + 1, t) = N(t, t) + N(t - 3, t) + 1 = 2
[by induction hypothesis b)].
Thus, N(t + 2, t + 1) = N(t + 1,t).
Induction hypothesis: For, t + 1 h s,
c) N(h, t + 1) N(h-1- t),
d) N(h, t + 1) = N(h - 1, t + 1)
+ N(h - 4,t + 1) + 1.
-
ACKNOWLEDGMENT
[12]
[13]
[14]
[15]
[16]
[17]
[18]
[19]
[20]
[21]
[22]
[23]
[24]
343
[25] J. A. Orenstein, "Multidimensional TRIEs used for associative searching," Inform. Proc. Lett., vol. 13, pp. 150-157, 1982.
[26] T. Ottmann, H. -W. Six, and D. Wood, "Right brother trees,"
Commun. Ass. Comput. Mach., vol. 21, pp. 796-776, 1978.
[27] T. Ottmann and D. Wood, "1-2 brother trees or AVL trees revisited,"
Comput. J., vol. 23, pp. 248-255.
[28] P. Scheuermann and M. Ouksel, "Multidimensional B-trees for
associative searching in database systems," Inform. Syst., vol. 7,
pp. 123-137, 1982.
[29] D. D. Sleator and R. E. Tarjan, "Self-adjusting binary search," in Proc.
15th Annu. Symp. on Theory of Computing, 1983, pp. 235-245.
[30] V. K. Vaishnavi, "Computing point enclosures," IEEE Trans. Comput.,
vol. C-31, pp. 22-29, 1982.
[31]
, "On the worst-case efficient implementation of weighted dynamic
dictionaries," in Proc. 21st Annu. Allerton Conf. on Communication,
Control, and Computing, 1983, pp. 647-655.
[32] V. K. Vaishnavi, H. P. Kriegel, and D. Wood, "Height balanced 2-3
trees," Computing, vol. 21, pp. 195-211, 1979.
[33] V. K. Vaishnavi and D. Wood, "Data structures for the rectangle
containment and enclosure problems," Computer Graphics and Image
Processing, vol. 13, pp. 372-384, 1980.
[34]
, "Rectilinear line segment intersection, layered segment trees and
dynamization," J. Algorithms, vol. 2, pp. 160-176, 1982.
Vijay K. Vaishnavi was born in Srinagar, Kashmir,
India. He received the B. E. degree (with distinction) in electrical engineering from the Jammu