Let QQ be a set of nn points in the plane. We say that point (x,y)(x, y) dominates point (x,y)(x', y') if xxx \ge x' and yyy \ge y'. A point in QQ that is dominated by no other points in QQ is said to be maximal. Note that QQ may contain many maximal points, which can be organized into maximal layers as follows. The first maximal layer L1L_1 is the set of maximal points of QQ. For i>1i > 1, the iith maximal layer LiL_i is the set of maximal points in Qj=1i1LjQ - \bigcup_{j = 1}^{i - 1} L_j.

Suppose that QQ has kk nonempty maximal layers, and let yiy_i be the yy-coordinate of the leftmost point in LiL_i for i=1,2,,ki = 1, 2, \dots, k. For now, assume that no two points in QQ have the same xx- or yy-coordinate.

a. Show that y1>y2>>yky_1 > y_2 > \cdots > y_k.

Consider a point (x,y)(x, y) that is to the left of any point in QQ and for which yy is distinct from the yy-coordinate of any point in QQ. Let Q=Q{(w,y)}Q' = Q \cup \{(w, y)\}.

b. Let jj be the minimum index such that yj<yy_j < y, unless y<yky < y_k, in which case we let j=k+1j = k + 1. Show that the maximal layers of QQ' are as follows:

  • If jkj \le k, then the maximal layers of QQ' are the same as the maximal layers of QQ, except that LjL_j also includes (x,y)(x, y) as its new leftmost point.

  • If j=k+1j = k + 1, then the first kk maximal layers of QQ' are the same as for QQ, but in addition, QQ' has a nonempty (k+1)(k + 1)st maximal layer: Lk+1={(x,y)}L_{k + 1} = \{(x, y)\}.

c. Describe an O(nlgn)O(n\lg n)-time algorithm to compute the maximal layers of a set QQ of nn points. (Hint:\textit{Hint:} Move a sweep line from right to left.)

d. Do any difficulties arise if we now allow input points to have the same xx- or yy-coordinate? Suggest a way to resolve such problems.

(Omit!)