Variations of Enclosing Problem Using Axis Parallel Square ( s ) : A General Approach

Let P be a set of n points in two dimensional plane. For each point p P ∈ , we locate an axisparallel unit square having one particular side passing through p and enclosing the maximum number of points from P . Considering all points p P ∈ , such n squares can be reported in ( ) O n n log time. We show that this result can be used to (i) locate ( ) m 2 > axis-parallel unit squares which are pairwise disjoint and they together enclose the maximum number of points from P (if exists) and (ii) find the smallest axis-parallel square enclosing at least k points of P , k n 2 ≤ ≤ .


Introduction
, , , n P p p p =  points in a plane, enclosing problem in computational geometry is concerned with finding the smallest geometrical object of a given type that encloses all the points of P .Some well known instances of the enclosing problem are finding minimum enclosing circle [1], minimum area triangle [2], minimum area rectangle [3], minimum bounding box [4], and smallest width annulus [5].
The k -enclosing problem is an important variant of enclosing problem.Here the objective is to compute a smallest region of given type that encloses at least k points of P .k -enclosing problems using rectangles and squares are studied [6]- [11] are also studied extensively.
A closely related problem locates one or more copies of a given region to maximize the size of the subset enclosed.In other words, instead of fixing k and computing an optimal enclosing region, the problem is to maximize the number of points enclosed by the given region(s) of fixed size and shape.This type of problem has similar applications as the problems mentioned above.These so called problems of maximal enclosing using single object, each of fixed size and orientation, have also received attention of many researchers.The objects used are circle [12] and convex polygon [13] [14].Younies et al. [15] introduced a zero-one mixed integer formulation for the maximum enclosing problem where points are enclosed by parallelograms in a plane.Directional antennas is one of the applications where parallelogram shapes would be useful.In the context of bichromatic planar point set, Díaz-Báñez et al. [16] proposed algorithms for maximal enclosing by two disjoint axis-parallel unit squares and circles in ( ) n time respectively [17].

Problems Studied
An axis-parallel unit square is a square of unit size whose sides are parallel to one of the coordinate axes.An axis-parallel unit square S encloses a set of points those lie on the boundaries of S or in the interior of S .
For a given set P of n points in two dimensional plane, in this paper we consider the following variation of the maximal covering problem.
• For each point p P ∈ , locate an axis-parallel unit square whose one side is constrained to pass through p and encloses the maximum number of points from P .
We propose an ( ) log O n n time and ( ) O n space algorithm to solve the problem P1.It is shown that this algorithm can be used to compute a placement of one or more axis-parallel squares enclosing the maximum number of points from P if such a placement exists.We also use this result to construct an efficient algorithm for finding the smallest axis-parallel square enclosing at least k points of P for large values of k .

Maximal Enclosing Problem
This section considers the following problem P1: For each point i p P ∈ , we locate an axis-parallel unit square whose one particular side is passing through i p and enclosing the maximum number of points from P .Note that such axis-parallel unit square may not be unique.In that case, choose one among them and call that axis-parallel unit square as candidate square.Therefore, at most 4n number of candidate squares can be obtained by considering alignments of four different sides for all points in P .Below we describe the pass for computing candidate squares whose bottom sides are passing through a point from P (See Figure 1).
Without loss of generality, assume that no two points have the same x -or y -coordinate.Consider two arrays x ∆ and y ∆ containing the points of P in ascending order of x and y -coordinates respectively.Let us denote the x -coordinate of the i-th entry of x ∆ by i x and similarly the y -coordinate of the i-th entry of y ∆ by i y , 1 i n ≤ ≤ .Coordinates of a generic point p is denoted by ( ) ( ) ( ) , x p y p .For a point p P ∈ , let ( ) left p denote the minimum entry in x ∆ , say q P ∈ , such that ( ) ( ) 1 x p x q − ≤ .Observation 1 Given the array x ∆ , all intervals can be computed in linear time.In a similar way, for a point p P ∈ , let ( ) bottom p denote the minimum entry in y ∆ , say q P ′ ∈ , such that ( ) ( )

Algorithm for Reporting Candidate Squares
In this section we present sweep line algorithm combined with balanced search tree as data structure for computing candidate squares.Using the points in array x ∆ , construct a balanced search tree T with search key as the x -coordinate values of the points in P .The leaves of T correspond to the ordered points of x ∆ .We attach two positive integral variables  and  with each node of T .Before describing the algorithm in details, we first explain the role of  and  .The span ( ) I v corresponding to an internal node v is an interval, generated by the x -coordinates of the left most and right most points at the leaves in the subtree rooted at v .Moreover, span ( ) I µ of the leaf node µ stores the x -coordinate of the point at the leaf node µ of T .Our sweep line algorithm considers two horizontal sweep lines namely bottom sweep line BS and top sweep line TS .Let the current positions of TS and BS be at heights ( ) y p and ( ) y q respectively such that ( ) and H be the unit horizontal slab determined by BS and TS .In case that the vertical distance between BS and TS is less than unity, shift TS upwards to create a gap between BS and TS as unity.Note that, no additional points are included for such shifting of TS in upward direction.
At the end of processing all points within H , we get the following information by  and  .The variable  attached with an internal node v indicates that there exists a subset ( ) of size  (i.e.,  stores the count of the set P′ ) such that each unit square whose bottom, top sides coincide with BS , TS respectively and left boundary within span ( ) I v encloses the subset P′ .Observe that these spans ( ) I v are all different for all nodes v .The subsets P′ for nodes along the path from root to a leaf node are all disjoint.
Here each node v does not keep P′ explicitly but only its count  .The variable  attached with an internal node v indicates that there exists a unit square S whose cardinality is the sum of  values of the ancestor nodes of v plus the  value at node v ; bottom and top sides of S are constrained to coincide with BS , TS respectively, the left boundary of S lies within the span ( ) I v .Moreover, the cardinality of S is maximum among all unit squares within the slab H and the left boundary of each such unit square lies within the span of v .We now recursively define  value for an internal node as the sum of its  value and the maximum of  values of its two children-nodes.This recursive definition of  implies that variable  at the root of tree T stores the cardinality of a candidate square whose bottom side is constrained to pass through the point q .This type of integral variables attached to the nodes of segment tree are also used to handle stabbing counting queries [18].The space requirement for this type of segment tree is linear [18].
In initial step, the variables  and  corresponding to all nodes are initialized with zero and both the sweep lines TS and BS pass through the bottom most point ( ) p .Assume that i p is the point corresponding to the i-th entry in y ∆ , 1 i n ≤ ≤ .The algorithm processes all points 1 2 , , , n p p p  in y ∆ one at a time.We also explain the way of capturing information by the variables  and  at the time of processing a point in y ∆ , encountered by sweep lines.The sweep line TS is moved up one point at a time, considering 1 p as the first encountered point.For each point p encountered by the sweep line TS , if the vertical distance of p from the current position of the sweep line BS is less than or equal to unity, T is updated by Increment operation which is described below.
For the interval  , find the split node [18] split v in T , that is the least common ancestor of ( ) ( ) and ( ) x p in the balanced search tree T .Search for the leaf node containing ( ) left p on the left subtree rooted at split v and, while traversing, if we turn left from node v , increment  of the right child of v by one.In case the right child of v is a leaf, increment its  instead of  .Similarly, while traversing the right subtree of the split node for searching the leaf node containing p , if we turn right from node v , increment  of the left child of v .Again, in case the left child is a leaf, increment its  instead of  .Finally, increase the  values of the leaf nodes containing ( ) left p and p by one.We now recursively update the  value of each internal node in the path from the leaf node containing ( ) left p to the left child of the split node split v , as the sum of its  value and the maximum of  values of its two children-nodes.Then update the  value of each internal node in the path from the leaf containing p to the root of T in similar way.In case , we find the leaf node v of T that contains the point p and increment the  value of leaf node v .The subsequent updation of  values associated with the internal nodes of T is same as described earlier.
Again if the vertical distance of the encountered point p by TS from the current position of BS becomes greater than unity, TS stops advancing to p (i.e., T is not updated by Increment operation for the point p ).For the point q on the current position of BS , update T for the point q and report a candidate square with bottom boundary passing though q by the Decrement and Report operations which are explained below.
The sweep line BS is then moved up one point at a time.For each point q encountered by the sweep line BS , if the vertical distance between p and q is greater than unity, T is updated by Decrement operation and a candidate square with bottom boundary passing though q is reported by Report operation.
In case that the vertical distance of q from TS becomes smaller than unity, the sweep line BS stops advancing and sweep line TS starts sweeping from its current position.The above process is continued till Report and Decrement operations are done for all the points.
We now describe the Report operation.Let q S be the candidate square with bottom boundary passing through the point q .Observe that the number of points enclosed by q S is equal to the  value at the root of the tree T .To find a placement of the left boundary of q S , move from the root of the tree T towards the leaf, each time picking the child with larger  value.The leaf node thus reached stores the point through which the left boundary of q S passes.Report q S along with the number of points inside it.The Decrement operation is same as Increment operation with the following exception.For the interval  associated with point q , locate the split node in T .During searching from the split node for the nodes containing ( ) left q and q , instead of incrementing, we decrement  's and  's by one as appropriate.The subsequent updation of  values associated with the internal nodes of T is similar to that in the Increment operation.
Theorem 1 Let P be a set of n points in a two dimensional plane.S be an axis-parallel unit square enclosing the maximum number of points from P and P P ′ ⊆ be the set of points enclosed by * S .Note that * S can always be repositioned, without altering the points enclosed by it, so that the extended lines of two adjacent sides of * S pass through two points of P and these two points may not belong to P′ .Sometimes the adjacent sides of * S may be passed through same point of P and, in that case, the point is at one corner of * S .Therefore, the maximum cardinality among the set of all possible candidate squares is equal to the cardinality of * S . Corollary 2 An axis-parallel rectangle of fixed height and width that encloses the maximum number of points from P , can be placed in and the problem is known to be NP-hard [19].A set of m rectangles (squares) on the plane is called m -sliceable if they can be recursively partitioned by ( ) horizontal or vertical lines [20].We now assume there exists m -sliceable axis-parallel squares and propose an algorithm to locate three axis-parallel unit squares which are pairwise disjoint and they together enclose the maximum number of points from P .Let Observe that among these three squares, one square is separated from other two squares by a horizontal or a vertical line.Without loss of generality, assume that the line separating one square from other two squares is vertical (first pass).The other pass where the line separation is horizontal, can be handled in similar manner.Now we are describing the first pass of our proposed algorithm.
Let the vertical line passing through the i-th point in array x ∆ divides the point set P into two sub-set i Q and i Q′ respectively; the subset i Q and i Q′ lie on the left and right side of this vertical line.For the position of the vertical line that passes through the i-point of x ∆ , the result in Corollary 3 is used to place a pair of disjoint squares enclosing the maximum number of points from i Q and the result in Corollary 1 to place a square that encloses the maximum number of points from i Q′ .This triplate of squares is a potential candidate for position of the vertical line that passes through the i -th entry of x ∆ .Observe that the time required to place these triplet of squares is . Similarly use the result in Corollary 1 to place a square that encloses the maximum number of points from i Q and the result in Corollary 3 to place a pair of disjoint squares enclosing the maximum number of points from i Q′ .This triplate of squares is also a potential candidate for position of the vertical line that passes through the i-th entry of x ∆ .Finally, a triplate of squares that together enclose greater number of points of P among the two sets of triplet of squares is Now this process is repeated for each position of the vertical line that passes though a point x p ∈ ∆ .We thus have the following result.
Corollary 4 Given a set P of n points in the plane, three axis-parallel unit squares which are pairwise disjoint and they together enclose the maximum number of points from P can be placed in ( ) and ( ) O n space.To solve the maximal enclosing problem using m axis-parallel unit squares, if we naively extend this approach then it is interesting to note that the solution would not have a polynomial time complexity in both n and m .Now to solve this problem, we propose an ( ) O m n time and ( )

4
O mn space algorithm that uses (i) similar dynamic programming approach as proposed by Mukherjee et al. [21], and (ii) the result in Corollary 1 as a subroutine.
Observe that placing horizontal and vertical partitioning lines among the points of P can generate ( )

4
O n subsets of P .Let ( ) be the subset of points enclosed by the minimum enclosing rectangle (MER) defined by the points ( ) ( ) ( ) x p y p and ( ) ( ) ( ) x p y p , i j < and l k < as bottom-left and top-right corners respectively.Given a subset ( ) Count x p y p x p y p m denote the maximum number of points from P jointly enclosed by m disjoint axis-parallel unit squares placed over the subset P′ .
In the first step, we compute ( Count x p y p x p y p for all possible subsets of P using the result in Corollary 1. Subsequently, it computes Count x p y p x p y p u for all possible subsets of P using the results of the previous steps in similar dynamic programming approach as proposed by Mukherjee et al. [21].Finally, it reports In view of the Corollary 1, computation of the first step requires ( ) n .Complexity of subsequent steps, and hence, the over all time complexity of the algorithm is ( ) O m n .Corresponding space complexity can also be shown to be ( ) O mn .Further details can be found in [21].We thus have the following result.Theorem 2 A placement of m sliceable axis-parallel unit squares which are pairwise disjoint and they together enclose the maximum number of points from P can be computed in ( ) O m n time using ( )

4
O mn space.

k-Enclosing Problem
Initially researchers considered the k -enclosing problem for computing a smallest area (perimeter) axis-parallel square or rectangle.Most of the algorithms proposed for k -enclosing problems are efficient when k is small and become inefficient for large values of k .Segal and Kedem [9]  Matoušek [22] developed ( ) ( ) , time algorithm to find a smallest k -enclosing circle that is especially efficient when k is close to n .Given a set P of n points in the plane and an integer k ( ) k n ≤ , we consider the problem of computing the minimum area axis-parallel square that encloses at least k points of P for large values of k .A k point enclosing square (rectangle) k S is said to be a k -square ( k - rectangle) if there does not exist another square (rectangle) having area less than that of k S and enclosing k points from P [10].
We use the idea of prune and search technique to solve the optimization problem for finding k S ( ) Each pruning step uses the solution of the corresponding decision problem that guides the search process.The decision version of this problem asks whether there exists a square of side length α that encloses at least k points where k and α are the input parameters.In Section 4, we present some preliminary observations and it is shown that the Result in Corollary 1 can be used to solve a decision version of the optimization problem.

Preliminaries
, , , n P p p p =  be the set of n points in the plane.Our objective is to compute k -square k S .
Without loss of generality, assume that no two points of P have the same x or y coordinates.Let ( ) x p and ( ) y p denote the x -coordinate and the y -coordinate of any point p respectively.The size a square is represented by the length of it's side.We have the following observation.
Observation 2 At least one pair of opposite sides of k S must contain points from P .The decision version of this problem can be stated as "given a length α , does there exist a square of size α that encloses at least k points of P ?".
Let n k − elements are on the right side of p .The position of p in the left to right ordering of P are at most k .Therefore there are ( ) points are on left of p .Hence right boundary of k S is on right side of p .Similarly left, top and bottom boundaries of k S are on left, top and bottom sides of p respectively.Hence the observation follows.
Let f R be the minimum area axis-parallel rectangle enclosing the point set f P .Suppose the length of the longest side of f R is λ and the left, right, top and bottom boundaries of the rectangle f R contain the points l p , r p , t p and b p respectively (See Figure 2).We define

( )
Max-square α , α λ ≥ as an axis-parallel square of size α that includes the point set f P and the total number of points enclosed from P is maximized.It is easy to see that the bottom, top, left and right boundaries of

An Efficient Algorithm to Find k-Square for Large Values of k
In this section, we explain an efficient algorithm to find k S for large values of 2  (    From Lemma 1, we get that at th j iterative step at least 4 M elements are discarded where M denotes the size of j ∆ .This leads to the following recurrence relation.
with maximum x -coordinates and minimum y -coordinates among the points in P respectively.Similarly, with maximum y -coordinates and minimum x -coordinates among the points in P respectively.
a smallest area k -enclosing axis-parallel rectangle for large values of k , sweep line paradigm combined with binary search tree as data structure in similar way as described in Section 2.1.As earlier, our algorithm makes horizontal and vertical sweeps.Below we briefly describe the algorithm for horizontal sweep to locate ( ) Max-square α whose bottom side is aligned with a point from P .Look for all squares of size α whose bottom and left boundaries are within the range
i > > .Without loss of generality, let the indices of the points , , and b p remain same in Q also.Let us denote the set of vertical distances generating ∆ by the sequences

l and 2 l
Note that the elements in each sequence i Ψ are in nondecreasing order.At th j iterative step of the algorithm the current search space j ∆ is reduced by pruning the i Ψ 's.Here, either upper or lower portion of i Ψ is pruned.Therefore, each i Ψ sequence can be represented by lower and upper indices of the original sequence.For any point i p Q ∈ , median element of the corresponding sequence i are the lower and upper indices of the sequence i Ψ .We denote the median element of i Ψ as ( ) i med Ψ .So computing the median of the sequence of vertical distances corresponding to any point i p Q ∈ requires only a constant time arithmetic operation on the array indices.We represent each i Ψ as a vertical strip parallel to the y -axis.All the vertical strips ( i Ψ 's) are arranged along the x -axis such that ( ) i med Ψ 's fall on the x -axis and the median values are in nonincreasing order along the x -axis (See Figure 3

Theorem 4
The technique used to derive the result in Theorem 3 can also compute k S for all values of k .Hence we have the following theorem.Given a set P of n points in the plane and an integer ( )k n≤ , the smallest area square enclosing at least k points of P can be computed in ( )2 log O nn time using linear amount of space.
Now, we sweep from bottom to top to generate a subset of y ∆ that reports the maximum cardinality candidate square whose top boundary lies below any point It is interesting to generalize the maximal enclosing problem using m disjoint axis-parallel unit squares, 2 m > O n time. Let p be any point of the set f P .At least ( ) either top and bottom sides of k S contain points of P or left and right sides of k S contain points of P .Without loss of generality, assume that top and bottom sides of k S contain points from P .The other case where left and right sides of k S contain points of P , can be handled in similar manner.Let Max-square α encloses k points of P and the value α ∈ ∆ is minimized.We iteratively reduce the size of ∆ by prune and search technique without explicitly computing ). Again the elements of each