Multidimensional Binary Search Trees Used for Associative Searching - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Multidimensional Binary Search Trees Used for Associative Searching

Description:

Communications of the ACM, September 1975, vol. 18, no. 9. 1975 ACM Student Award ... 1. if P contains only one point then. 2. return a leaf storing this point ... – PowerPoint PPT presentation

Number of Views:195
Avg rating:3.0/5.0
Slides: 8
Provided by: Jos373
Category:

less

Transcript and Presenter's Notes

Title: Multidimensional Binary Search Trees Used for Associative Searching


1
Multidimensional Binary Search Trees Used for
Associative Searching
  • Jon Louis Bentley
  • Stanford University
  • Communications of the ACM, September 1975, vol.
    18, no. 9
  • 1975 ACM Student Award
  • Paper Second Place

2
Notations
  • Let P be a set of n points in the plane.
  • A 2-dimensional rectangle range query on P asks
    for the points from P lying inside a query
    rectangle x xy y.
  • A point p(px,py) lies inside this rectangle if
    and only if x?px?x and y?py?y.

3
Construction
  • Algorithm BUILDKDTREE(P,depth)
  • //Input A set of points P and the current depth.
  • //Output The root of a kd-tree storing P.
  • 1. if P contains only one point then
  • 2. return a leaf storing this point
  • 3. else if depth is even then
  • 4. Split P into two subsets with a
    vertical line l through the median x-coordinate
    of the points
  • in P. Let P1 be the set of points to the left and
    P2 be the set of points to the right. Points
    exactly on
  • the line belong to P1.
  • 5. else
  • 6. Split P into two subsets with a
    horizontal line l through the median
    y-coordinate of the points
  • in P. Let P1 be the set of points above l and P2
    be the points below l. Points exactly on the line
    belong
  • to P1.
  • 7. Vright BUILDKDTREE(P1,depth1)

4
Query
Algorithm SEARCHKDTREE(v,R) Input. The root of
a (subtree of a) kd-tree and a range R. Output.
All points at leave below v that lie in the
range. 01 if v is a leaf 02 Report the point
stored at v if it lies in R. 03 else 04 if
region(lc(v)) is fully contained in R 05
ReportSubtree(lc(v)) 06 else 07 if
region(lc(v)) intersects R 08
SEARCHKDTREE(lc(v),R) 09 if region(rc(v)) is
fully contain in R 10 ReportSubtree(rc(v)) 11
else 12 if region(rc(v)) intersects R 13
SEARCHKDTREE(rc(v),R)
5
Insertion
6
Demo
  • http//www.rolemaker.dk/nonRoleMaker/uni/algogem/k
    dtree.htm

7
Discussion
  • Priority search trees v.s. Kd-trees
Write a Comment
User Comments (0)
About PowerShow.com