The convex hull of a set of points in is the smallest convex set that contains . We denote the convex hull of by and denote the set of extreme points in by . Let and . Note that because is a subset of . By computing the convex hull of , we mean outputting the points in in clockwise order.
There is a long line of research on computing the convex hull using space. In the RAM model, Graham  gave the first algorithm, called the Graham Scan, with running time . Subsequently, several algorithms were devised with the same running time, but with different approaches [33, 2, 25, 6]. In the output-sensitive model, where the running time depends on and , Jarvis  proposed the Gift Wrapping algorithm, which has running time . This algorithm was later improved by Kirkpatrick and Seidel  and Chan , both of which achieve running time of . In the online model, where input points are given one by one and algorithms need to compute the convex hull of points seen so far, Overmars and van Leeuween’s algorithm  can update the convex hull in time per incoming point. Brodal and Jacob  reduced the update time to .
Streaming Model. The algorithms mentioned above all require working space (memory) in the worst case. Therefore, none of these can handle the case when , that is, when either is very large (a massive data set) or is very small (such as in embedded systems). In order to explore the convex hull problem with such a memory restriction, we consider the standard streaming models [35, 5, 16, 31, 15], where the given points are stored on a read-only or writable tape in an arbitrary order. If the tape is read-only, then the model is simply called the streaming model [5, 31]. Otherwise the tape is writable, and the model is called the W-stream model [35, 16, 15]. We refer to algorithms in the streaming model as streaming algorithms and algorithms in the W-stream model as W-stream algorithms. In both models, algorithms can manipulate the working space while reading the points sequentially from the beginning of the tape to the end; however, only algorithms in the W-stream model can modify the tape, detailed in Section 4. Hence, algorithms in this model cannot access the input randomly, which is different from the model for in-place algorithms [10, 8]. The extreme points are written to a write-only stream. The pass complexity of an algorithm refers to the number of times the algorithms scans the tape from the beginning to the end. The goal is to devise streaming and W-stream algorithms that have small pass and space complexities.
No single-pass streaming algorithm can compute the convex hull using space because it is no easier than sorting positive numbers in . Since sorting numbers using spaces requires passes , computing the convex hull in a single pass requires linear space. However, Chan and Chen  showed that the space requirement can be significantly reduced if multi-pass algorithms are allowed. Specifically, their streaming algorithm uses passes, space, and time for any constant . On the other hand, to have small space complexity, one can appeal to a general scheme to convert PRAM algorithms to W-stream algorithms established by Demetrescu et al. , summarized in Section 4. Using this technique yields a W-stream algorithm that uses passes and space where can be as small as constant.
Our Contribution. We devise a new -time RAM algorithm to compute the convex hull (Section 2). Then, we adapt the RAM algorithm to both models.
In the streaming model, the pass complexity of our algorithm is roughly a square root of that of Chan and Chen’s algorithm  if both algorithms have the same space usage. Specifically, we have:
Given a set of points in on a read-only tape where , there exists a deterministic streaming algorithm to compute the convex hull of in passes using space and time for every constant .
In the W-stream model, we adapt the RAM algorithm to two W-stream algorithms. One uses space for any and the other uses space for any . The pass complexity of our W-stream algorithms are and , which are smaller than
, the best pass complexity among those W-stream algorithms that are converted from PRAM algorithms in algebraic decision tree model, when .
The first W-stream algorithm is deterministic, and we get:
Given a set of points in where , there exists a deterministic W-stream algorithm to compute the convex hull of in passes using space and time for any .
Next, we randomize the above W-stream algorithm. A logarithmic factor can be shaved off from the pass complexity w.h.p.333 w.h.p. means with probability
w.h.p. means with probability. We have:
Given a set of points in where , there exists a randomized W-stream algorithm to compute the convex hull of in passes using space and time for any , where w.h.p.
We prove that our W-stream algorithms have nearly-optimal tradeoff between pass and space complexities by showing Theorem 4, which generalizes Guha and McGregor’s lower bound (Theorem 8 in ). We remark that this lower bound is sharp because it matches the bounds of our randomized W-stream algorithm when .
Given a set of points in where , any streaming (or W-stream) algorithm that computes the convex hull of with success rate , and uses bits requires passes.
We note here that space is measured in terms of bits for lower bounds and in terms of points for upper bounds. This asymmetry is a common issue for geometric problems because most geometric problems are analyzed under the RealRAM model, where precision of points (or other geometric objects) is unbounded.
Applications. Our W-stream algorithms can handle the case for because it outputs extreme points on the fly. This output stream can be used as an input stream for another streaming algorithm, such as for diameter  and minimum enclosing rectangle , both of which rely on Shamos’ rotating caliper method . We apply Theorems 2 and 3 to show Corollary 5, detailed in Section 7.
Given a set of points in where , there exists a deterministic W-stream algorithm to compute the diameter and minimum enclosing rectangles of in passes using space and time for every . Given randomness, the pass complexity can be reduced to w.h.p.
Approximate Convex Hulls. Given the hardness result shown in Theorem 4, we know that one cannot have a constant-pass streaming algorithm that uses space to compute the convex hull. In view of this, to have constant-pass -space streaming algorithms, one may consider computing an approximate convex hulls. There are several results studying on how to efficiently find an approximate convex hull in the streaming model, based on a given error measurement. The error criterion varies from the Euclidean distance , and Hausdorff metric distance [28, 29], to the relative area error . These algorithms use a single pass, space, and can bound the given error measurement by a function of .
Paper Organization. In Section 2, we present a new -time RAM algorithm to compute the convex hull. Then, in Section 3, we present a constant-pass streaming algorithm in the streaming model. In Section 4, we present two W-stream algorithms, both of which use space where can be as small as . We generalize the previous lower bound result in Section 5, and prove a higher (but conditional) lower bound in Section 6. We place the proofs of Corollary 5 in Section 7.
2 Yet another -time algorithm in the RAM model
Our streaming algorithm is based on a RAM algorithm, which we present in this section. This RAM algorithm is a modification of Kirkpatrick and Seidel’s ultimate convex hull algorithm in the RAM model . Chan and Chen’s streaming algorithm  is also based on Kirkpatrick and Seidel’s algorithm, and thus the structure of these two streaming algorithms have some similarities. The changes are made so that our streaming algorithm does not have to rely on solving linear programs, thus reducing the computation cost compared to Chan and Chen’s algorithm.
In what follows, we only discuss how to compute the upper hull because the lower hull can be computed analogously. Formally, computing the upper hull of a point set means outputting that part of the extreme points in clockwise order so that is the leftmost point in and is the rightmost point in , tie-breaking by picking the point with the largest -coordinate, so that all points in lie below or on the line passing through for each . Note that each of has a unique -coordinate, and each line that passes through and for has a finite slope.
Roughly speaking, Kirkpatrick and Seidel’s ultimate convex hull algorithm  evenly divides the point set into two subsets by a vertical line , finds the hull edge in the upper hull that crosses , and recurses on the two separated subsets. By appealing to the point-line duality, finding the crossing hull edge is equivalent to solving a linear program. Chan and Chen’s streaming algorithm is adapted from this implementation of the ultimate convex hull algorithm. Their algorithm evenly divides the point set into subsets for by vertical lines, finds the hull edges in the upper hull that cross these vertical lines, and recurses on the separated subsets. Finding these crossing hull edges is equivalent to solving linear programs, where the constraint sets for each are the same but the objective functions are different.
|Find hull edges, and recurse.||Find extreme points, and recurse.|
|Kirkpatrick and Seidel 1986 ||Chan 1995 |
|any||Chan and Chen 2007 ||This paper|
In [11, Section 2], Chan gives another version of Kirkpatrick and Seidel’s ultimate convex hull algorithm, that finds a suitable (possibly random) extreme point, divides the point set into two by -coordinate, and recurses. The extreme point can be found by elementary techniques. Our streaming algorithm is adapted from the latter algorithm. It finds suitable extreme points for , divides the point set into subsets by -coordinate, and recurses on each subset. Though this generalization sounds straightforward, finding the suitable extreme points needs a different approach from that for finding a single suitable extreme point. We reduce finding these suitable extreme points to computing the upper hulls of small point sets. This reduction is the key observation of our RAM algorithm and is described in detail in the subsequent paragraphs. These four algorithms are categorized in Table 1.
Given , our algorithm partitions arbitrarily into so that each has size in , and then computes the upper hull of each . Let be the union of the slopes of the hull edges in the upper hull of , , …, , which is a multiset. Let be the slope of rank in , for , in other words, is the th
-quantile in. To simplify the presentation, let and . Let be the extreme point in that supports slope , for each . That is, for every point draw a line passing through with slope , and pick as the point whose line has the highest -intercept. We define , the point with the smallest -coordinate, and , the point with the largest -coordinate. If any has more than one candidates, pick the point that has the largest -coordinate. Let denotes the -coordinate of point , and let denote the slope of the line that passes through points and .
We use these as the suitable extreme points with which to refine into where we say the are suitable in that each has size bounded by . Initially, set for all . The refinement applies the cascade-pruning described in Lemma 7 on for each , which uses the known pruning technique stated in Lemma 6 as a building block, and works as follows:
Compute , and obtain the extreme points in clockwise order.
Set for each , where (resp. ) is the extreme point in that supports (resp. ).
The pruning in Step 2 is two-fold. For any , if , then such a cannot be placed in . Otherwise , and Case 2 of Lemma 7 applies. Again, such a cannot be placed in . Similarly, for any cannot be placed in either. Finally, remove the points that lie below or on the line passing through from for each .
Lemma 6 (Chan, ).
Given a point set and a slope , let be the extreme point in that supports . Then, for any pair of points where ,
If and , then .
If and , then .
Lemma 7 (Cascade-pruning).
Given a point set and a slope , let be the extreme point in that supports . Then, for any whose , , and where is such that is the extreme point in that supports , we have:
If for some , then .
If for some , then .
Observe that for all and for all because are extreme points in in clockwise order and is the extreme point in that supports . Since there is an such that , we have for each . The above are exactly the conditions of Case 1 in Lemma 6 for all point pairs whose . Thus, for all . The other case can be proved analogously. ∎
We get the exact bound for each in Lemma 8, noting that for .
To ensure that, for every , is a small fraction of , we use the cascade-pruning procedure described in Lemma 7. Let be for some where . Let (resp. ) be the extreme point in that supports (resp. ).
Let be the number of points in . Recall that does not contain any for any , and hence . Observe that point pair has slope in the open interval for each . Since (resp. ) is the -th largest slope (resp. the -th largest slope) in , has at most slopes in the open interval . This yields that
The last inequality holds because , and it establishes that the number of points from all ’s that comprise for each is at most . ∎
For each , if , then our algorithm recurses on . This ensures that every subproblem has an input that contains some intermediate extreme point(s), i.e. not the leftmost and rightmost extreme points, and any two subproblems where one is not an ancestor or a descendant of the other have an empty intersection in their intermediate extreme point set. As a result,
Our algorithm has leaf subproblems.
We need Lemma 9 to analyze the running time.
Here we analyze the running time of the RAM algorithm for the case of and defer the discussion for the case of until the section on streaming algorithms. Let be the recursive computation tree of the RAM algorithm. The root of represents the initial problem of the recursive computation. Every node in has at most child nodes, each of which represents a recursive subproblem.
For a computation node with the input point set whose , we use any -time algorithm to compute the convex hull. Otherwise, we need to compute convex hulls of point sets of size at most , which runs in time (Lines 1-9). In addition, the quantile selection in has the running time (Line 11). The suitable extreme points can be found in time by Lemma 15 (Line 12). The pruning procedure can be done in time by a simple merge (Lines 15-26). Hence, each computation node needs time.
Since each child subproblem has an input set of size at most (Lemma 8), the running time of child subproblem is an -fraction of its parent subproblem. Hence, is an -fading computation tree where Edelsbrunner and Shi  define a recursive computation tree to be -fading for some if the running time of a child subproblem is an -fraction of its parent. In , Chan extends Edelsbrunner and Shi’s results and obtains that, if an -fading recursive computation tree has leaf nodes and the total running time of the nodes on each level is at most , then the recursive computation tree has total running time . Our algorithm has leave nodes (Lemma 9) and time for the computation nodes on each level because two subproblems on the same level have their inputs only intersected at one of their extreme points. We get:
The RAM algorithm runs in time, and for it is an -time algorithm.
3 A Simpler and Faster Streaming Algorithm
In this section, we show how to adapt our RAM algorithm to the streaming model. Our streaming algorithm is the same as our RAM algorithm, but we execute the subproblems on in BFS order. That is, starting from the root of , all subproblems on
of the same level are solved together in a round, then their invoked subproblems are solved together in the next round, and so on. We will see in a moment that our algorithm needs to scan the inputtimes for each round. Therefore, to have an -pass streaming algorithm, our approach requires for some positive constant . By setting , we have:
By setting the parameter to be for any constant , the recursive computation tree has nodes.
We assign a unique identifier to each of subproblems. Let be the subproblem on whose identifier is . For each , has input point set . is a subsequence of and is given to as an input stream of points. Our algorithm will generate more than once for to access, for all . The data structures used in also are suffixed with . To compute , naively we need space. We will see in a moment that given , how to solve using space in time. We will also see how to generate the input for all the subproblems on of depth in passes. We now establish all these claims, after which we will be ready to prove Theorem 1. We decompose into the following three subtasks and describe the algorithms for the subtasks in the subsequent subsections.
Given , obtain the quantile slopes .
Given and , obtain the suitable extreme points .
After the ancestor subproblems of (excluding ) are all solved, generate .
3.1 Obtaining the quantile slopes
To find the quantile slopes for (Lines 1-11 in the RAM algorithm) using small space, we use a Greenwald and Khanna  quantile summary structure, abbreviated as . This summary is a data structure that supports two operations: insert a slope (.insert(
)) and query for (an estimate of) the-th smallest slope (.query()) in . Given access to , we do not have to store the entire to obtain the quantile slopes. Instead, we invoke .insert() for each slope . After updating all slopes in , we obtain an estimate of the -quantile of by invoking .query() for all . The detailed implementation of the above adaption to the streaming model is given in Algorithm 1.
.query() returns an estimate that has an additive error in the rank, where is a parameter to be determined. We set for some constant so that the additive error cannot increase the depth of by more than a constant factor. Precisely, because the obtained has the rank in the range
The summary needs space, and therefore the space usage for each subproblem is . In , it shows that Greenwald and Khanna’s quantile summary needs time for an update and for a query. Because conducts updates and queries, we get:
Given , there exists a streaming algorithm that can obtain the approximate quantile slopes in to within any constant factor using time and space.
3.2 Obtaining the suitable extreme points
To find the suitable extreme points in (Line 12 in the RAM algorithm), a naive implementation, which would update the supporting points of for all once for each point , needs running time. To reduce the running time to the claimed time complexity , we need the following observation.
For any non-singleton set whose extreme points in the upper hull from left to right are , the point in that supports a given slope is
To find the extreme points in that supports for all , we compute the extreme points in from left to right, generate a (sorted) list of slopes , and merge with another (sorted) list of the approximate -quantile slopes . By Observation 14, the point in that supports for each can be easily determined by the its predecessor and successor in . Scanning the merged list suffices to get . Though the above reduces the time complexity to , the space complexity is much higher than the claimed space complexity for . To remedy, again, we reduce this problem to computing the upper hulls of smaller point sets. First, we partition arbitrarily into so that each group has size points. Then, for each we apply the above accordingly, detailed in Algorithm 2. We get:
Given and sorted , there exists a streaming algorithm that can obtain the extreme points in that support for all using time and space.
3.3 Generating the input point set for each subproblem
Recall that we execute the subproblems in in BFS order. Upon executing the subproblems of depth for any , all the subproblems of depth less than are done and the associated quantile slopes and suitable extreme points are memoized in memory. For , we need to generate the input for the initial problem . Because its input point set is exactly , scanning over suffices.
Given the associated quantile slopes and suitable extreme points for all the subproblems of depth less than , to generate the input point sets for all the subproblems of depth , we can directly execute Lines 15-26 in the RAM algorithm for all the subproblems of depth less than and ignore Lines 1-14 because the intermediate values, the quantile slopes and suitable extreme points, are already computed and kept in memory. Initially, we allocate a buffer of size for each subproblem of depth less than so as to temporarily store the incoming input points, i.e. points in . Then, we scan on the input tape once and for each input point in , we place in the buffer of . Once any buffer gets full or the input terminates, we let be some , a part in the partition of , and apply the pruning procedure stated in Lines 15-26 in the RAM algorithm. Those points that survive the pruning are flushed, one by one, into the buffers of ’s child subproblems. We apply the above iteratively until we reach the end of the input tape. The space usage counted on each is and the overall running time to generate the input point set for all the subproblems of depth is because all the subproblems of each depth computes the upper hull of points sets, disjoint subsets of . Hence, we get:
There exists a streaming algorithm that can generate the input for all the subproblems on of depth for each using passes, space, and time.
Proof of Theorem 1.
For , has nodes and depth by Lemmas 11 and 8. Hence, the space complexity of our streaming algorithm is the sum of times the space complexity in Lemmas 13 and 15, and times the space complexity in Lemma 16. The overall space complexity is . One can obtain the space bound by checking whether before proceeding to the subproblems on the next depth, where is the number of subproblems executed so far and thus . If so, we compute the convex hull by a RAM algorithm.
Analogously, we have that the pass (resp. time) complexity of our streaming algorithm is (resp. ) ∎
4 A W-Stream Algorithm Of Nearly-Optimal Pass-Space Tradeoff
Theorem 17 (Demetrescu et al. ).
If there exists a PRAM algorithm that uses processors to compute the convex hull of given points in rounds, then there exists an -space -pass W-stream algorithm to compute the convex hull.
There is a long line of research that studies how to compute the convex hull of given points efficiently in parallel [14, 4, 3, 1, 18, 22]. In particular, Akl’s PRAM algorithm  uses processors and runs in time for any . Converting Akl’s PRAM algorithm to a W-stream algorithm by Theorem 17, we have:
There exists an -pass W-stream algorithm that can compute the convex hull of given points using space.
The optimal work, i.e., the total number of primitive operations that the processors perform, for any parallel algorithm in the algebraic decision tree model444Roughly speaking, algorithms are decision trees in which each computation node is able to test the sign of the evaluation of a constant-degree polynomial. to compute the convex hull is [27, 22]. Therefore the W-stream algorithm stated in Corollary 18 is already the best possible among those W-stream algorithms that are converted from a PRAM algorithm in the algebraic decision tree model by Theorem 17. However, in this Section, we will show that such a tradeoff between pass complexity and space usage is suboptimal by devising a W-stream algorithm that has a better pass-space tradeoff. Together with the results shown in Section 5, we have that the pass-space tradeoff of our W-stream algorithm is nearly optimal.
4.1 Deterministic W-stream Algorithm
Our deterministic W-stream algorithm is the same as our streaming algorithm, except for the following differences:
We set (rather than ) for our deterministic W-stream algorithm. Thus, by Corollary 12 increases from to , but the space usage of subproblem decreases from to for each . Moreover, if the extreme point in the input that supports the approximate median slope is the leftmost point or the rightmost point , i.e. the degenerate case, we replace it with the extreme point that supports . In this way, each subproblem on has a unique extreme point and therefore the number of subproblems on is .
Our streaming algorithm executes the subproblems on in BFS order, that is, all subproblems of depth are executed in a round for each . In contrast, our deterministic W-stream algorithm refines a single round into subrounds, in each of which it takes care of subproblems, so as to bound the working space by .
Note that algorithms in the W-stream model are capable of modifying the input tape. Formally, while scanning the input tape in the -th pass, algorithms can write something on a write-only output stream; in the -th pass, the input tape read by algorithms is the output tape written in the -th pass. Hence, our deterministic W-stream algorithm is able to assign an attribute to each point to indicate that is an input of a certain subproblem. Moreover, our deterministic W-stream algorithm can write down the parameters for every subproblem on the output tape. In each subround, our deterministic W-stream algorithm needs to scan the input twice. The first pass is used to load the parameters of subproblems to be solved in the current subround. The second pass is used to scan the input tape and process the points that are the input points for the subproblems to be solved in the current subround.
We are ready to prove Theorem 2.
Proof of Theorem 2.
Suppose there are subproblems of depth on for each , then our deterministic W-stream algorithm has to execute
subrounds for any . Because our deterministic W-stream algorithm scans the input tape twice for each subround, the pass complexity is .
As shown in Section 3, subproblem needs running time. Since the input of subproblems of depth on are disjoint subsets of , for each . We get that the time complexity is . ∎
4.2 Randomized W-stream Algorithm
Observe that for , finding the approximate quantile slopes in is exactly finding the approximate median slope in . Our algorithms mentioned previously all use Greenwald and Khanna quantile summary structure, which needs space. In our randomized W-stream algorithm, we replace the Greenwald and Khanna quantile summary with a random slope in , thereby reducing the space usage to . As noted by Bhattacharya and Sen , such a replacement cannot increase the depth of by more than a constant factor w.h.p. Consequently, we get Theorem 3.
5 Unconditional Lower Bound
In this section, we will show that any streaming (or W-stream) algorithm that can compute the convex hull with success rate using space requires passes (i.e. Theorem 4). This establishes the near-optimality of our proposed algorithms. We note here that the lower bound holds even if the output is the quantity , rather than the set .
We construct a point set so that it is hard to compute the convex hull of point set for all , as illustrated in Figure 1. Let be concentric half circles. The radius of equals 1 and that of is any value in for some to be determined later. Let be points distributed evenly on so that and . Define on similarly. Let be the distance between the origin and the line for any