330 likes | 476 Views
Is 2 1D better than 2D?. Andrej Brodnik 1 , Mirko Zadravec 2 , Borut Žalik 2 1 University of Primorska & University of Ljubljana 2 University of Maribor. Outline. Problem definition Data structures used 2D data structures 2 1D data structures Empirical results
E N D
Is 2 1D better than 2D? Andrej Brodnik1, Mirko Zadravec2, Borut Žalik2 1University of Primorska & University of Ljubljana 2 University of Maribor
Outline • Problem definition • Data structures used • 2D data structures • 2 1D data structures • Empirical results • Conclusions or practice vs. theory Andrej Brodnik: Is 2 x 1D better than 2D?
Problem • 2D space with n points • Incremental insertion: For all points p do: ds.Insert(p); ds.Neighbour(p); • Incremental dynamic version of Post-office problem (Knuth) • M. Smid, Closest-Point Problems in Computational Geometry Andrej Brodnik: Is 2 x 1D better than 2D?
Data structures • No rocket science, just that it has to work • 2D: • no Voronoi diagram, • kd-trees, O(log n) • 2 1D: hashing and • Red-black trees • (a,b)-trees • (a,b)-deterministic skip lists Andrej Brodnik: Is 2 x 1D better than 2D?
2 1D Andrej Brodnik: Is 2 x 1D better than 2D?
2 1D • Number of stripes: m • Expected number of points in stripe T (Mannila et al.) T= C n * ln n/ln ln n m= n/T = 1/C n * ln ln n/ln n w= (xmax-xmin)/m C 0.6 (in tests: 0.2 < C < 1) • Inserted points are randomized Andrej Brodnik: Is 2 x 1D better than 2D?
2 1D • Algorithm: InsertAndFind(p): stripe= p.x/w; DS1D[stripe].Insert(p); Neighbour(p); Andrej Brodnik: Is 2 x 1D better than 2D?
2 1D Andrej Brodnik: Is 2 x 1D better than 2D?
2 1D • Two cases: • Need to search many stripes – O(m)= o(n) • Number of candidates is big and they are arranged on a circle – O(n) Andrej Brodnik: Is 2 x 1D better than 2D?
RB-trees, (a,b)-DSL and (a,b)-trees • trees: neighbors linked • (a,b)-DSL: • between two high nodes are p lower nodes (a p b) • O(log n) time and O(n) space • (a,b)-trees: • B-trees with p children (a p b) but possibly at root • O(log n) time and O(n) space • b < 30, a = b/2 Andrej Brodnik: Is 2 x 1D better than 2D?
Operations • We count the following operations: • Steps to find stripe and through the DS to find the spot for the point • Rotations necessary to balance the DS • Search in the secondary DS up or down to find the candidate • Jumps to neighboring stripes • Search in the secondary DS in neighboring stripes • Measure: average # of operations / inserted point Andrej Brodnik: Is 2 x 1D better than 2D?
Gaussian distribution • Gaussian distribution • 10.000 points • 100.000 points • 1.000.000 points Andrej Brodnik: Is 2 x 1D better than 2D?
Gaussian distribution – 10k Operations/point: min 20.12, max= 50.24 Andrej Brodnik: Is 2 x 1D better than 2D?
Gaussian distribution – 100k Operations/point: min 22.64, max= 57.81 Andrej Brodnik: Is 2 x 1D better than 2D?
Gaussian distribution – 1M Operations/point: min 24.60, max= 70.62 Andrej Brodnik: Is 2 x 1D better than 2D?
Grid distribution • Grid distribution • 10.000 points • 100.000 points Andrej Brodnik: Is 2 x 1D better than 2D?
Grid distribution – 10k Operations/point: min 18.36, max= 49.38 Andrej Brodnik: Is 2 x 1D better than 2D?
Grid distribution – 100k Operations/point: min 20.68, max= 61.52 Andrej Brodnik: Is 2 x 1D better than 2D?
Grid distribution – 1M Operations/point: min 24.35, max= 75.75 Andrej Brodnik: Is 2 x 1D better than 2D?
Uniform distribution • Uniform distribution • 10.000 points Andrej Brodnik: Is 2 x 1D better than 2D?
Uniform distribution Operations/point: min 19.26, max= 49.90 Andrej Brodnik: Is 2 x 1D better than 2D?
Ellipsis distribution • Points on an elliptic arc • 10.000 points Andrej Brodnik: Is 2 x 1D better than 2D?
Ellipsis distribution Operations/point: min 12.92, max= 44.00 Andrej Brodnik: Is 2 x 1D better than 2D?
Circular distribution • Points on a circle with a point in the centre • 10.000 points Andrej Brodnik: Is 2 x 1D better than 2D?
Circular distribution Operations/point: min 7.50, max= 42.26 (2514,99) Andrej Brodnik: Is 2 x 1D better than 2D?
Combination of distributions • Mixture of clustered, Gaussian and uniform distribution • 100.000 points Andrej Brodnik: Is 2 x 1D better than 2D?
Combination of distributions Operations/point: min 23.90, max= 64.16 Andrej Brodnik: Is 2 x 1D better than 2D?
Lena’s distribution • Dark pixels from a rastered Lena • 114.215 points Andrej Brodnik: Is 2 x 1D better than 2D?
Lena’s distribution Operations/point: min 13.24, max= 568.81 Andrej Brodnik: Is 2 x 1D better than 2D?
GIS data • Real GIS data: border stones between the lots • 70.433 points Andrej Brodnik: Is 2 x 1D better than 2D?
GIS data Operations/point: min 20.59, max= 61.29 Andrej Brodnik: Is 2 x 1D better than 2D?
Conclusions • Need a better model? • Average and amortized analysis • Why m= 1/C n * ln ln n/ln n Andrej Brodnik: Is 2 x 1D better than 2D?