10 - Grids
Published online by Cambridge University Press: 05 September 2016
Summary
A two-dimensional grid is a matrix of c columns and r rows, where each cell may or may not contain a point. We call n the total number of points in the grid. In the basic case, points have no associated data. We will also consider the case of weighted points, where the points have an associated integer priority (or weight) in the range [1, u].
Grids arise naturally in applications related to geographic information systems (GIS), computational geometry, and multidimensional data in general, but also as internal components of other data structures that are not related to geometry. We have already seen applications in Chapter 9 (the adjacency matrix), where graph edges (v, u) were modeled essentially as points on a grid of size |V| × |V|.
In this chapter we focus on a more geometric interpretation of grids, where queries refer to the points lying on a two-dimensional range of the grid. We consider the following queries on a grid G:
count(G, x1, x2, y1, y2): returns the number of points lying on the rectangle [x1, x2] × [y1, y2] of G, that is, within the column range [x1, x2] and at the same time within the row range [y1, y2].
report(G, x1, x2, y1, y2): reports the (x, y) coordinates of all the points lying on the range [x1, x2] × [y1, y2] of G.
top(G, x1, x2, y1, y2,m): reports m points (x, y) with highest priority in the range [x1, x2] × [y1, y2] of G, for the case of weighted points.
Algorithms to solve related problems, like determining whether a rectangular area is empty, or reporting points in some specific coordinate order, will be derived as modifications of these three queries. Although much less ample than the complex queries that may arise in computational geometry applications, the basic queries on axis-aligned areas cover the needs of a large number of applications and are amenable to efficient solutions.
- Type
- Chapter
- Information
- Compact Data StructuresA Practical Approach, pp. 347 - 394Publisher: Cambridge University PressPrint publication year: 2016