Published online by Cambridge University Press: 05 September 2016
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.
To save this book to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.