Mesh of Trees Solution

11.5.3 Mesh of Trees Solution

Assume that a set S =

... , of points in the plane is given, where each point

is represented by its Cartesian coordinates, that is,

Our first parallel algorithm for computing

is designed to run on a mesh of trees SIMD computer. In order to avoid cluttering our presentation with "hairy" details, we make the following two simplifying assumptions.

(i) no two points have the same x or y coordinates and (ii) no three points fall on the same straight line.

Once we have described the approach upon which our algorithm is based, it will become obvious how to modify it to deal with situations where the preceding assumptions do not hold. We begin by explaining three ideas that are central to our

solution.

1. Identifying Extreme Points. Assume that the extreme points, that is, the points with maximum x coordinate, maximum y coordinate, minimum x coordinate, and minimum y coordinate in S, have been determined as shown in Fig.

11.10. Call these points XMAX, YMAX, XMIN, and YMIN, respectively. Three facts are obvious:

(i) The extreme points are vertices of (ii) any points falling inside the quadrilateral formed by the extreme points is

definitely not a vertex of

and

11.5 A Construction Problem 293

Figure 11.10 Extreme points of planar set.

(iii) the problem of identifying has been reduced to finding a convex polygonal path joining two extreme points in each of the regions 1, 2, 3, and 4;

is obtained by linking these four paths.

is an edge of if and only if all the n - 2 remaining points of S fall on the same side of an infinite straight line drawn through and

2. Identifying Hull Edges.

A segment

This property is illustrated in Fig. 11.1 1, where (a, b) is a convex hull edge while (c, and (e, f ) are not. Note that this allows us to conclude that both a and b are vertices of

be consecutive vertices of

3. Identifying the Smallest Angle. Let and

and assume that is taken as the origin of coordinates. Then, among all points of S, forms the smallest angle with with respect to the (either positive or negative) axis. This is illustrated in Fig. 11.12.

We are now ready to present our algorithm. Assume that a mesh of trees is available consisting of n rows and n columns of processors. The processor in row i and column j is denoted

j). For i =

. . , n, j) contains the coordinates

(i) all the processors in a column contain the coordinates of the same point of S and

(ii) the coordinates contained in a row form the set S = {(x,,

Figure

11.11 Property of convex hull

edges.

Figure 11.12 Property of consecutive

11.5 A Construction Problem The algorithm consists of the following stages.

Stage

(i) The processors in rows 1,

2, 3, and 4 compute XMAX, YMAX, XMIN, and YMIN and store their coordinates in P(l,

P(3, and P(4, respectively. (ii) Using the tree connections, first in column 1 and then in row 1, the coordinates

P(2,

of the four extreme points are made known to all processors in row 1.

Stage 2

(i) The four processors in row 1 corresponding to the extreme points produce a 1 as output [indicating these points are vertices of (ii) All processors in row 1 corresponding to points inside the quadrilateral formed by the extreme points produce a [indicating these points are not vertices of and should therefore be removed from further consideration].

(iii) Each of the remaining processors j ) in row 1 identifies the region or

4) in which point falls and communicates this information to all processors j ) in column j. (iv) XMAX is assigned to region 1, YMAX to region 2, XMIN to region 3, and YMIN to region 4.

Stage 3

If processor

i) corresponding to point of S produced neither a 1 nor a in stage

2, then the following steps are executed by the processors in row i: (i) The point

(in the same region as is found such that forms the smallest angle with respect to (a) the positive x axis if

is in regions 1 or 2 or

(b) the negative axis if

is in regions 3 or 4.

(ii) If all remaining points (in the same region as and fall on the same side of an infinite straight line through

and

then

is a vertex of

Stage 4

(i) If was identified as a vertex of in stage 3, then P(l, i) produces a 1 as output; otherwise it produces a

(ii) An arbitrary point in the plane is chosen inside the quadrilateral whose corners are the extreme points. This point (which need not be a point of S) is designated as an origin for polar coordinates. The polar angles formed by all points identified as vertices of

are computed.

296 Computational Geometry Chap. 11 (iii) The angles computed in (ii) are sorted in increasing order using the mesh of trees

(see problem 4.2). This gives the convex hull vertices listed in counterclockwise order, exactly in the sequence in which they appear along the boundary of

Analysis. Each of the four stages requires operations. Thus

the algorithm's cost is O(n 2 log n), which is not optimal. As in previous sections the cost can be reduced to O(n 2 ) by using n rows of processors each. This cost is still not optimal in view of the

n). Since

sequential algorithm described in section 11.5.2.