Académique Documents
Professionnel Documents
Culture Documents
{74{
VS
Ch. 4
{75{
VS
{ k-d Trees
{ Point Quadtrees
{ MX-Quadtrees
Ch. 4
Example Maps
{76{
VS
Ch. 4
k -D
Trees
{77{
VS
Ch. 4
{78{
VS
Node Structure
nodetype = record
INFO: infotype;
XVAL: real;
YVAL: real;
LLINK: "nodetype
RLINK: "nodetype
end
INFO
LLINK
XVAL
YVAL
RLINK
Ch. 4
{79{
VS
Level of nodes is dened in the usual way (with root at level 0).
Def: A 2-d tree is any binary tree satisfying the following condition:
Ch. 4
{80{
VS
BanjaLuka (19,45)
BanjaLuka (19,45)
BanjaLuka (19,45)
Derventa (40,50)
Derventa (40,50)
Toslic (38,38)
(a)
(b)
(c)
BanjaLuka (19,45)
BanjaLuka (19,45)
Derventa (40,50)
Toslic (38,38)
Sinj (4,4)
Derventa (40,50)
Toslic (38,38)
Tuzla (54,40)
(d)
Level:0
Level:1
Level:2
Tuzla (54,40)
Level:3
(e)
Ch. 4
{81{
VS
elds.
If so, just overwrite node T and we are done.
Else, branch left if N:XV AL < T:XV AL and branch right
otherwise.
Suppose P denotes the child we are examining. If N and P
agree on their XVAL and YVAL elds. just overwrite node
P and we are done, else branch left if N:Y V AL < P:Y V AL
and branch right otherwise.
Repeat this procedure, branching on XVAL's when we are at
even levels in the tree, and on YVALs when we are at odd
levels in the tree.
Ch. 4
Example of Insertion
{82{
VS
(XVAL,YVAL)
(19,45)
(40,50)
(38,38)
(54,35)
(4,4)
Ch. 4
Example of Insertion
{83{
VS
Ch. 4
{84{
VS
N:Y V AL = y.
If N is a leaf node, then set the appropriate eld (LLINK
or RLINK) of N 's parent to NIL and return N to available
storage.
Otherwise, either the subtree rooted at N:LLINK (which
we will denote by T`) or the subtree rooted at N:RLINK
(which we will denote by Tr ) is non-empty.
(Step 1) Find a \candidate replacement" node R that occurs either in Ti for i 2 f`; rg.
(Step 2) Replace all of N 's non-link elds by those of R.
(Step 3) Recursively delete R from Ti.
The above recursion is guaranteed to terminate as Ti for i 2
f`; rg has strictly smaller height than the original tree T .
Ch. 4
{85{
VS
This means that the desired replacement node R must satisfy the
property that:
1. Every node M in T` is such that: M:XV AL < R:XV AL if
level(N ) is even and M:Y V AL < R:Y V AL if level(N ) is
odd.
2. Every node M in Tr is such that: M:XV AL R:XV AL if
level(N ) is even and M:Y V AL R:Y V AL if level(N ) is
odd.
Ch. 4
{86{
VS
Ch. 4
{87{
VS
Ch. 4
{88{
VS
Ch. 4
Point Quadtrees
{89{
VS
qtnodetype = record
INFO: infotype;
XVAL: real;
YVAL: real;
NW,SW,NE,SE: "qtnodetype
end
Ch. 4
{90{
VS
Root
region represented
by node N
Node N
N.NW
N.SW
N.NE
N.SE
Ch. 4
{91{
VS
(XVAL,YVAL)
(19,45)
(40,50)
(38,38)
(54,35)
(4,4)
Ch. 4
{92{
VS
Ch. 4
{93{
VS
Ch. 4
{94{
BanjaLuka (19,45)
VS
BanjaLuka (19,45)
NW SW NE SE
Derventa (40,50)
(a)
Derventa (40,50)
(b)
(c)
BanjaLuka (19,45)
Derventa (40,50)
BanjaLuka (19,45)
Toslic (38,38)
Sinj (4,4)
Derventa (40,50)
Tuzla (54,35)
(d)
Toslic (38,38)
Toslic (38,38)
Tuzla (54,35)
(e)
Ch. 4
{95{
VS
Ch. 4
{96{
VS
end
Case
N.XLB
N.XUB
N.YLB
N.YUB
N=P.NW
P.XLB
P.XLB + 0 5 P.YLB + 0 5
P.YUB
N=P.SW
P.XLB
P.XLB + 0 5
P.YLB
P.YLB + 0 5
N=P.NE P.XLB + 0 5
P.XUB
P.YLB + 0 5
P.YUB
N=P.SE P.XLB + 0 5
P.XUB
P.YLB
P.YLB + 0 5
w
Ch. 4
{97{
VS
Ch. 4
{98{
VS
Ch. 4
{99{
VS
Ch. 4
{100{
VS
Thus, in general, deletion of an interior node N may require reinsertion of all nodes in the subtrees pointed to
by N:NE , N:SE , N:NW and N:SW . In the worst case,
this may require almost all nodes to be reinserted.
Ch. 4
{101{
VS
2. else
(a) If (T:XV AL; T:Y V AL) 2 C then print (T:XV AL; T:Y V AL);
(b) RangeQueryPointQuadtree(T.NW,C);
(c) RangeQueryPointQuadtree(T.SW,C);
(d) RangeQueryPointQuadtree(T.NE,C);
(e) RangeQueryPointQuadtree(T.SE,C);
end proc
Ch. 4
The MX-Quadtree
{102{
VS
Ch. 4
The MX-Quadtree
{103{
VS
Example:
Ch. 4
The MX-Quadtree
{104{
VS
Ch. 4
{105{
Insertion in MX-Quadtrees
VS
nw swne se
(a)
(b)
(c)
(d)
Ch. 4
Insertion in MX-Quadtrees
{106{
VS
Ch. 4
Deletion in MX-Quadtrees
{107{
VS
Ch. 4
{108{
VS
Ch. 4
R-Trees
{109{
VS
Ch. 4
R-Trees
{110{
VS
Ch. 4
{111{
VS
Ch. 4
{112{
VS
Example R-Tree
R1 R2 R3
G3
R4 R5 R6 R7
R8 R9
Leaf Nodes
rtnodetype = record
Rec1; : : :; RecK : rectangle;
P1; : : :; PK : "rtnodetype
end
Ch. 4
{113{
VS
Ch. 4
(a)
{114{
VS
(b)
Ch. 4
{115{
VS
Ch. 4
{116{
VS
Deletion in R-Trees
Deletion of objects from R-trees may cause a node in the Rtree to \under
ow" because an R-tree of order K must contain
at least dK=2e rectangles (real or group) in it.
When we delete a rectangle from an R-tree, we must ensure
that that node is not \underfull."
R1 R2 R3
G3
R4 R5 R6 R7
R8 R9
Leaf Nodes
Ch. 4
{117{
VS
Deletion in R-Trees
R1 R2 R3
G1 G2
G3
R4
R6 R7
R5 R9
Leaf Nodes
Medical databases
Multimedia databases
Operations
Operations
Indexing
Techniques
Application
Applications
insert, delete,
exact/partial match
B-tree, hash
indexing
Data warehouse
2-10
GIS
>10
X-tree, TV-tree,
M-tree
Multimedia
databases, Medical
databases
search engine,
data mining
>50
The X-tree
TV-tree
R1 is selected over R2
because
the
resulting
region will have a smaller
radius