ExternalMemory Computational

Preliminary Version

y z x

Michael T Go o drich JyhJong Tsay Darren Erik Vengro Jerey Scott Vitter

The Johns Hopkins National Chung Cheng Brown University Duke University

University University devcsbrownedu jsvcsdukeedu

goodrichcsjhuedu jjtcsccuedutw

Abstract Largescale problems involving geometric data are

ubiquitous in spatial geo

graphic information systems GIS con

In this paper we give new techniques for designing

straint logic programming ob ject oriented

ecient for computational geometry prob

databases systems and

lems that are too large to be solved in internal memory

graphics As an example NASAs so on

and we use these techniques to develop optimal and

tob e p etabytesized databases are designed to facili

practical algorithms for a number of important large

tate a variety of complex geometric queries Im

scale problems We discuss our algorithms primarily

p ortant op erations on geometric data include range

in the context of single processorsingle disk machines

queries constructing convex hulls nearest neighb or

a domain in which they are not only the rst known

calculations nding intersections and to

optimal results but also of tremendous practical value

name but a few

Our methods also produce the rst known optimal al

gorithms for a wide range of twolevel and hierarchical

Our IO mo del

multilevel memory models including paral lel models

The algorithms are optimal both in terms of IO cost

In IO systems data are usually transferred in units

and internal computation

of blocks which may consist of several kilobytes This

blo cking takes advantage of the fact that the seek time

Intro duction

is usually much longer than the time needed to trans

fer a record of data once the disk readwrite head is

InputOutput IO communication b etween fast

in place An increasingly p opular way to get further

internal memory and slower secondary storage is the

sp eedup is to use many disk drives andor many CPUs

b ottleneck in many largescale informationpro cessing

working in parallel We mo del such

applications and its relative signicance is increasing

systems examples of which are shown in Figure us

as parallel gains p opularity In this pap er

ing the following four parameters

we consider the imp ortant application area of compu

tational geometry and develop several paradigms for

M items that can t in internal memory

optimal geometric computation using secondary stor

B records p er blo ck

age

P CPUs internal pro cessors

This research was supp orted in part by the National Science

D disk drives

Foundation under Grants CCR and IRI and

by the NSF and DARPA under Grant CCR

y

For the problems we consider we dene three general

This research was supp orted by the National Science Coun

cil under grant NSCE Republic of China parameters

z

This research was supp orted in part by Army Research Of

ce grant DAALG and by National Science Foun

N items or up dates in the problem instance

dation grant DMR Author is currently visiting Duke

K query op erations in the problem instance

University email devcsdukeedu

x

This research was supp orted in part by National Science

T items in the solution to the problem

Foundation grant CCR and by Army Research Oce

grant DAALG

Our results

D ּ D

e present a numb er of general tech a)ּ (b) In this pap er w)              

       

niques for designing externalmemory algorithms for

computational geometry problems These techniques

include the following

distribution sweeping a generic metho d for ex

ternalizing planesweep algorithms

persistent Btrees an oline metho ds for con

structing an optimalspace p ersistent version of

the Btree For batched prob

this gives a factor of B improvement over

Internal Internal lemsInternal Internal

generic p ersistence techniques of Driscoll et

memory memory thememory memory

al

Figure a The parallel disk mo del Each of the

batch ltering a general metho d for p erform

D disks can simultaneously transfer B records to and

ing K simultaneous externalmemory searches in

internal memory in a single IO The internal

from CPU CPU CPU

data structures that can b e mo deled as a planar

memory can store M DB records b Multipro ces

layered dags

generalization of the IO mo del in a in which

sor CPU

each of the P D internal pro cessors controls one

external marriagebeforeconquest an external

disk and has an internal memory of size M P The

memory analog to the wellknown technique of

P pro cessors are connected by some top ology such as

Kirkpatrick and Seidel for p erforming output

a hyp ercub e or an EREW PRAM and their memories

e hull constructions

“Thesensitiv Net”

collectively have size M

We apply these techniques to derive optimal

externalmemory algorithms for the following funda

We will assume that M N P M log M

mental problems in computational geometry com

and DB M The measures of p erformance

puting the pairwise intersection of N orthogonal seg

that we would like to minimize simultaneously are the

ments answering K range queries on N p oints con

numb er of IOs and the internal computation time

structing the d and d of N p oints

The relevant terms that enter the formul for the

p erforming K p oint lo cation queries in a planar sub

IO b ounds are often in units of blo cks such as N B

division of size N nding all nearest neighb ors for a

M B and so on For that reason we dene the fol

set of N p oints in the plane nding the pairwise in

lowing shorthand notation

tersections of N rectangles computing the measure of

M K T N

the union of N rectangles computing the visibility of

N segments from a p oint p erforming K raysho oting

B B B B

queries in CSG mo dels of size N as well as several

In order to get across our techniques in the mini

geometric dominance problems Our results are sum

mum space we illustrate our results in this pap er to

marized in the following theorem individual parts of

the sp ecial case of the IO mo del in which P and

which are discussed in the remaining sections of the

D Even in this simplied mo del our results are

pap er

extremely signicant as P and D accurately

mo dels the vast ma jority of IO systems currently in

Theorem Each of the problems mentioned in

stalled and b eing pro duced yet no optimal algorithms

the preceding paragraph can be solved in external mem

were previously known for the problems we discuss

ory using O log IOs If D disks are

Additionally our results are optimal in the general

used in paral lel the number of IOs required can be

IO mo del and in the parallel hierarchy mo dels In

reduced by a factor of D

particular in the IO mo del using P pro cessors re

For problems in which there are no queries as part of duces the internal computation time by a factor of P

the problem instance we use K and thus and using D disks reduces the numb er of IO steps by

if the output solution size is xed we use T and a factor of D This is discussed in greater detail in

thus B o

Section and in the full version of this pap er

we will use is the problem of rep orting all intersecting Distribution sweeping

pairs from a set of N orthogonal line segments This

The wellknown plane sweep paradigm is a p ow

problem is imp ortant in graphics and VLSI design sys

erful approach for developing computational geome

tems

try algorithms that are ecient in terms of internal

We dene the sweep in terms of a vertical sweep of

computation In this section we develop a new plane

the plane by a horizontal line The xco ordinates of

sweep approach that for the rst time achieves opti

the vertical segments dene the total order and the

mal IO p erformance and a subsequent improvement

y co ordinates of their endp oints dene the sweepline

in practice for a large numb er of largescale oline

up date events in The y co ordinates of the hori

problems in computational geometry Sp ecic exam

zontal segments dene the sweepline query events in

ples that we explore include orthogonal segment inter

section batched range queries computing all nearest

Initially we use an optimal sorting so

neighb ors rectangle intersection and union computa

that endp oints of all segments are in two sorted lists

tions visibility among a set of nonintersecting line

one sorted by x and the other by y We now partition

segments and d maxima

the p oints into de vertical strips Now the sweep

i

We assume we are given a sequence

ing b egins progressing from top to b ottom As we

such that each is an up date op eration

1 2 N i

sweep we will rep ort some of the segment intersections

of the form insert x or delete x where each such x

and distribute data to recursive subproblems that we

is taken from a known total order The sequence

can solve to nd the rest When the top endp oint of

corresp onds to the sequence of up date op erations dur

a vertical segment is encountered the segment is in

ing the sweep In addition we are given a sequence

serted into an active list A asso ciated with the strip

i

such that each is a query op eration

1 2 K i

in which the segment lies and later when the b ot

i

query j which is dened as some kind of search in

tom endp oint is encountered the segment is deleted

a search tree dened on by p erforming the op era

from A When we encounter a horizontal segment

i

tions We assume without loss of general

1 2 j

R we consider the strips that R passes completely

ity that the s are sorted by their j arguments The

i

through and rep ort all the vertical segments in the ac

problem is to determine the answer to each query

i

tive lists of those strips Note that horizontal segments

One obvious externalmemory solution to this prob

are only distributed to the two strips containing their

lem is to implement the search tree as a dynamic B

endp oints thus at each level of recursion each segment

tree and to p erform the queries in in an online

is represented only twice Once the numb er of p oints

fashion while p erforming the up dates in Unfortu

in a recursive subproblem falls b elow M we simply

nately this requires N K log B

solve the problem in main memory This pro cess is

log IO op erations in the worst case which is

illustrated in Figure

prohibitive Previous work using lazy batched up dates

Insertions and vertical segments can b e pro cessed

on the Btree yielded algorithms with O log

2

eciently using blo cks With the exception of deleting

IOs

segments from active lists the total numb er of IOs

In Sections and we show how to p erform

p erformed by this metho d is optimal O log

the queries using only O log IOs which is

where T B and T is the numb er of intersections

optimal The lower b ound follows by a simple reduc

rep orted If vigilant deletion is used to delete each

tion from the sorting problem which has the same IO

segment as so on as the sweepline reaches the b ot

b ound as a lower b ound Our new metho d uses an

tom endp oint a nonoptimal O N O B term

oline topdown implementation of the sweep which

is added to the IO b ound Instead we use the fol

in turn is based up on a novel application of the sub

lowing lazy approach For each strip we maintain

division technique used by in the distribution sort

a stack of insertions pro cessed so far When a new

algorithms of It is for this reason that we

segment is inserted we simply add it to the stack

refer to our technique as distribution sweeping

We keep all but the most recently added B elements

of this stack in blo cks of size B in external memory

An example orthogonal segment in

When we are asked to output the active list we scan

tersection rep orting

the entire stack outputting the segments still current

Before discussing the distribution sweeping as a and removing the segments whose deletion time has

general technique let us b egin with a simple exam passed A simple amortization argument shows that

ple illustrating the main ideas involved The example this metho d achieves the b ound of Theorem

distribution sorting algorithms Asymptotically par

titioning the input in this manner do es not aect the

overall running time of an algorithm since it increases

d

e

the depth of recursion by only a constant factor of

g

b

We make use of this lemma to pro cess the up dates

c

f

and the queries as follows We rst merge and

a

into a single list ordered by index This can b e done in

O IOs by a simple merging pro cedure Moreover

during this same merging pro cedure we can construct

the set X of all elements referenced in p ossibly with

duplicates We then apply Lemma to partition X

into X X X by the ordering Since the op

1 2 s

erations in and are dened for a tree structure or

dered by this distribution immediately implies that

each and can b e decomp osed into sub op erations

i i

and such that

i1 i2 is i1 i2 is ij

resp is dened on X The sp ecic denitions of

ij j

these sub op erations will of course dep end up on the

Figure Distribution sweeping for orthogonal seg

application Note that in the example given in Sec

ment intersection Supp ose the sweep line moving

tion they were recursively solving the problem in

down from the top has reached horizontal segment

the strips Since and are dened for a tree struc

i

a At this p oint the active lists for the four strips are

ture ordered by only O sub op erations resp

ij

A fbg A fc dg A fe f g and A fg g

involve a recursive search in X for any i The

1 2 3 4

ij j

Note that this assumes lazy deletion At this p oint

other sub op erations for X involve an up date or query

j

the intersections of a and c d and f are rep orted

that can b e p erformed by a single scan ordered by i

b ecause a fully spans and Note that the in

through these nonrecursive and op erations

2 3

ij ij

p

tersection of a and b will not b e rep orted until the

we may p erform these nonrecursive Since s is O

problem is solved recursively on e and g are now

sub op erations as well as construct an ordered list of

1

deleted from A and A resp ectively Finally we dis

each sequence of recursive sub op erations by a single

3 4

tribute the p oints to the subproblems corresp onding

pass through the combined list We form all the re

to the strips

cursive sublists simultaneously in main memory using

p

MB B As so on as a bucket s buckets of size

lls we empty its contents out to external memory

General distribution sweeping

During this pass for each j we also maintain an active

bucket in main memory that stores information such

In this section we present the distribution sweeping

as counts sums or p ointers into external memory

technique at a high level Our metho d is based up on

for the elements in X present after p erforming the

j

the following distribution lemma which we will use

op erations on the elements of X up to the current

j

to distribute input data into recursive subproblems

one a or The active buckets are used to

ij ij

answer the nonrecursive sub op erations Having p er

Lemma Let S be a set of N elements

formed all the nonrecursive sub op erations we then

taken from some total order and let S be stored

recursively p erform each sequence of recursive sub in N B blocks in external memory Then using

op erations in turn A single pass requires only O only O IO operations S can be partitioned into

p

p

IOs and results in s subsequences made up of O s

e d M B e subsets S S S such s d

1 2 s

N N 3 1

blo cks each which requires only O blo cks for all

jS j and each element in that for al l i

i

2 s 2 s

the subsequences combined Thus the total numb er

S is less than each element in S

i i+1

of IOs needed is O log O log

s

p

Note that this lemma divides the input into d e

subsets whereas in the example in the previous sec

Other applications of distribution

tion we divided the input into de strips The dier

sweeping

ence is that this lemma do es not require the input to

Though space precludes a full exp osition the distri b e sorted by the ordering b efore it is partitioned

in fact this lemma was originally proven for use in

bution sweeping metho d can b e used to solve a num

b er of other oline problems in computational ge sth element in each list as a bridge element and we

ometry that are traditionally solved by plane sweep merge these bridge elements into a single list Y We

techniques The resulting algorithms use an optimal store p ointers from each element y Y to all its bridge

O log IOs Problems in this cate predecessors in the recursivelyconstructed lists The

gory include batched range queries nding all nearest list Y together with these p ointers denes the ro ots

neighb ors computing the visibility from a p oint in the of the p ersistent structure Since we only cho ose every

plane nding pairwise rectangle intersections com sth element from each list as a bridge it is easy to see

puting the measure of a union of rectangles and the that total space needed is O blo cks and the depth

d maxima problem These problems are discussed of the resulting layered dag p ersistent structure is

in greater detail in the full version of this pap er O log

A search in the past say at time p osition i b egins

by lo cating the ro ot active for time i and searching

Persistent Btrees

down in the structure from there always searching in

The Btree data structure is a fundamental

no des whose time stamp is the largest time stamp less

structure for maintaining a dynamicallychanging dic

than or equal to i Performing only one such search

tionary in external memory In some cases however

would not b e an ecient strategy however unless s

p

it may b e advantageous to b e able to access previous

is O B Nevertheless as we show in the next

versions of the data structure Being able to access

section this is a very ecient data structure eg

such previous versions is known as persistence and

for p oint lo cation if it is searched using the batched

there exist very general techniques for making most

ltering technique

data structures p ersistent Persistence can b e im

plemented either in an online fashion ie where the

Batch ltering

tree up dates are coming online or in an oline fash

ion ie where one is given the sequence of tree up

In this section we demonstrate how for many query

dates in advance

problems in computational geometry we can represent

For the online case the metho d of Driscoll et

a data structure of size N in disk blo cks in such a

al can b e applied to hysterical Btrees as de

way that K constant sized output queries of the data

structure can b e answered in O log IO scrib ed by Maier and Salveter Since it is online

op erations Because we represent the data structure this structure requires O N log IOs to construct

which is optimal in an online setting Unfortunately

as a dag through which the K queries lter down from

this is a factor of B away from optimal for the sort of

source to sinks we call this technique batch ltering

batch geometric problems we would like to consider

Given a data structure that supp orts queries we

For these we need an oline strategy that requires

can often mo del the pro cessing of a query as the

only O log IOs In the following section we de

traversal of a decision dag isomorphic to the data

scrib e just such a metho d

structure We b egin at a source no de in the dag and

at each no de we visit we make a decision based on

Oline p ersistence

the outcome of comparisons b etween the query value

and some numb er d of values stored at the no de We

In the oline case we can build a p ersistent tree

then make a decision as to which of the no des O d

by the distribution sweep metho d We slightly mo dify

children to visit next This pro cess continues until we

our application of distribution sweeping for this con

reach a sink in the dag at which p oint we rep ort the

struction however in that we follow the recursive calls

outcome of the query

on the sequences of sub op erations by a nonrecursive

By restricting the class of such dags we are willing

merge step

to consider we are able to prove the following lemma

We b egin by applying the Lemma to divide the

which will serve as a building blo ck for optimal al

set X of elements mentioned in into s groups of

gorithms to solve a numb er of imp ortant geometric

p

e This of size roughly N s each where s d

problems

course divides into s subsequences one for each

Lemma Let G V E be a planar layered de group We then recursively construct a p ersistent data

cision dag with a single source such that the maximum structure for each subsequence Each such recursive

out degree of any node is Let the graph be repre call returns a list of ro ots of sway trees each of

sented in blocks with the nodes ordered by level and which is marked with a time stamp that represents the

the nodes within a level ordered from left to right Let index in when this ro ot was created We mark every

N jV j and let h be the height of G We can lter K like a ary tree augmented with catalogs Clearly we

inputs through G in O h IO operations can apply the technique of Lemma to the main

tree but the bridge p ointers connecting the catalogs

Pro of Sketch We traverse the levels one by one

make the dag nonplanar To get around this we note

sending all K inputs to the ith level b efore any are

that as queries traverse the edges b etween no des in

sent to the i st We do this by maintaining two

the main tree they are ordered by the catalog val

FIFO queues one for the current level and one for

ues they query This ordering is established at the

the next level Each such queue is left to right list of

ro ot of the data structure where a ary tree is used

edges b etween its level and the next one If less than B

to lo cate the queries in the rst catalog By relying

inputs traverse an edge then they are explicitly stored

on this ordering we can eciently pro cess the queries

in the queue If B or more traverse the edge then

that arrive at each no de of the main tree The over

the queue contains a p ointer to a linked list of blo cks

all complexity of this technique is thereby maintained

storing them Since the graph is planar there exists

at O log Full details of the construction

an eciently blo cked metho d of pro ducing one queue

app ear in the full version of the pap er

form the previous queue 2

Luckily the restrictions imp osed on the typ e of de

cision dags we can handle with batch ltering is not

The convex hull problem is that of computing the

to o severe In particular many computations use de

smallest convex p olytop e completely enclosing a set

cision trees which clearly constitute a sp ecial case of

of N p oints in ddimensional space This problem

the lemma Often these trees are binary but we can

has imp ortant applications ranging from statistics to

divide a binary tree into layers of height O log and

graphics to metallurgy In this section we will ex

then store each no de on a layer b oundary along with

amine the problem in external memory for two and

all its descendants in the layer b elow it as a single no de

three The threedimensional case is par

with branching factor This allows us to reduce h

ticularly interesting b ecause of the numb er of two

by a factor of O log yet still meet the conditions of

dimensional geometric structures closely related to it

the lemma We will see this approach used in solving

such as Voronoi diagrams and Delaunay triangula

subproblems of the d convex hull problem in Sec

tions In fact by wellknown reductions our

tion

d convex hull algorithm immediately gives external

Another way of using batch ltering as is to b e

memory algorithms for planar Voronoi diagrams and

seen in Section is by structuring more complicated

Delaunay triangulations with the same IO p erfor

decision dags as recursive constructions to get around

mance

the planarity restrictions of the lemma

In main memory the lower b ound for computing

the convex hull of N p oints in d is

Application multiplep oint planar

N log N in the worst case In secondary mem

p oint lo cation

ory this b ound b ecomes log In this section we

Planar p oint lo cation is one of the fundamental

give optimal algorithms that match this lower b ound

problems of computational geometry In the version of

For the twodimensional case we show how to b eat

the problem considered here we are given a monotone

this lower b ound for the case when the output size T is

planar decomp osition having N vertices and a series

much smaller than N in the extreme case T O

of K query p oints For each query p oint we are to

We develop an outputsensitive algorithm based up on

return the identier of the region in which it lies In

an externalmemory version of the marriageb efore

main memory this problem can b e solved in optimal

conquest paradigm of Kirkpatrick and Seidel

time O N K log N using fractional cascading

Our d convex hull is somewhat esoteric so we

O N log N is sp ent on prepro cessing and O K log N

also describ e a simplied version which although not

is needed to p erform the queries

optimal asymptotically is simpler to implement and

Tamassia and Vitter have demonstrated a

will b e faster for the vast ma jority of practical cases

technique by which the fractional cascading used to

solve this problem can b e implemented in parallel

A worstcase optimal twodimen

Their technique can solve our problem in O N p

sional convex hull algorithm

K log N time on a PRAM with p pro cessors We

p

For the twodimensional case a numb er of main can use a metho d based on their construction but us

memory algorithms are known that op erate in optimal

ing in place of p to get a data structure that lo oks

time O N log N A simple way to solve the prob sort to more advanced divide and conquer approaches

lem optimally in external memory is to mo dify one One idea is to use a plane to partition the p oints

of the main memory approaches namely Grahams into equally sized sets recursively construct the con

scan Grahams scan requires that we sort the vex hull for each set and then stitch the recursive

p oints which can b e done in O log IO op era solutions together in linear time Unfortunately we

tions and then scan linearly through them at times know no way of implementing an algorithm of this typ e

backtracking but only over each input p oint at most in secondary memory the problem is that we cannot

once Clearly this scanning stage can b e accomplished adequately anticipate all p ossible paths through the

in O IO op erations so the overall complexity of data that might b e traversed during the combining

the algorithm is O log phase Another obstacle is that we need to b e able

to stitch together O recursive solutions in linear

An outputsensitive twodimensional

time rather than just two If we use any fewer then

convex hull algorithm

the depth of the recursion will not b e small enough to

give us an optimal algorithm

If the output size T is signicantly smaller than N

In order to get around the problems asso ciated with

for example T can b e O then we can do b etter

a merging approach we use a novel formulation of the

than the Graham scan approach In this section we

distribution metho d We consider the dual of the con

show how to construct a twodimensional convex hull

vex hull problem namely that of computing the inter

using a numb er of IOs that is outputsize sensitive in

section of a set of N half spaces all of which contain

a stronger sense than any of the algorithms discussed

the origin Standard geometric transforma

thus far Note that when T oN we actually do

tions are used to show the equivalence of convex

b etter than Theorem indicates Our results are

hull and halfspace intersection Once we are dealing

optimal as stated in the following theorem

with the dual problem we can use a distribution based

Theorem Let S be a set of N points in the plane

approach along the lines of that prop osed by Reif and

whose convex hul l has T extreme points If is O B

Sen for computing d convex hulls in parallel

for some constant then the convex hul l of S can

Let S b e a set of N halfspaces all of which contain

be computed in O log IOs which is optimal

the origin Let the b oundary of a halfspace h S

i

We omit details in this preliminary version but the

b e denoted P Supp ose we have a subset S S

i 0

T

main idea of our metho d is as follows First we ob

such that jS j N Let I h A face of

0 0 j

h 2S

j 0

serve that we may restrict our attention to the up

I might have up to N edges We can reduce this

0

p er hull ie edges with normals with p ositive y

complexity by trangulating each face which can b e

comp onents without loss of generality We use the

done by sorting the vertices of I along a vector not

0

Lemma to divide the set of input p oints into s

p erp endicular to any face and then sweeping a plane

p

e buckets divided by vertical lines We then use d

along this sorted order By Eulers law the size of the

an externalmemory implementation of a metho d of

resulting set of faces is at most O N We can now

Go o drich for combining pruneandsearch bridge

decomp ose I into O N cones C each of which has

0 i

nding with the Graham scan technique to

one of these faces as a base and the origin as an ap ex

nd all the upp er hull edges intersecting our given

An obvious way of distributing the halfspaces into sub

vertical lines Our implementation uses O IOs

problems is to create a subproblem for each cone C

i

Given these hull edges we may then recurse on any

consisting of nding the intersection of all halfspaces

buckets that are not completely covered by the hull

h S nS whose b ounding planes P intersect C Un

j 0 j i

edges we just discovered Our analysis is based on the

fortunately a given P may intersect many cones so it

j

fact that in any such divide step we either reduce the

is not clear that we can continue to work through the

numb er of p oints under consideration by a constant

O log log N required levels of recursion without caus

fraction or we will discover s hull edges p ossibly

ing a very large blow up in the total size of the sub

b oth If is O B for some constant this

problems Luckily using a form of random sampling

implies that the total numb er of IOs is O log

called p olling and eliminating redundant planes from

which is optimal for any value of T

within a cone prior to recursion we can with high

get around this problem In this discus

Threedimensional convex hulls

sion the phrase with high probability means with

probability N for some constant

Even in main memory sweep plane algorithms fail

to solve the d convex hull problem and we must re

Algorithm is the resulting distribution algo

Halfspace Intersection

are actually random variables It suces to use Karps

Input A set S of N halfspaces in d space

metho d for solving probabilistic recurrence relations

Output The set of all halfspaces h S whose b ounding

i

T

to get the optimal solution T n O log

planes lie on the b oundary of the intersection h

j

h S

j 0

with high probability

For j to log take a random sample S of

j

The distribution approach used here is dierent

S where jS j N for a constant

j

from those of the distribution sort algorithms for the

Recursively solve the halfspace intersection problem

various IO and memory hierarchy mo dels

on each sample S giving a set of solutions I

j j

but has the same asymptotic IO complexity In the

distribution sorting there are two sets of recursive Use p olling to estimate the size of the partition

of S S that each sample solution I will induce

calls rather than one but the time to partition is

j j

Let S b e the sample whose solution I generates the

r r

faster

smallest such partition

If desired the randomization in our algorithm can

For each cone C of I compute R the set of halfs

i r i

b e removed by an external memory implementation of

paces in S S whose b oundaries intersect C

r i

the technique in Details are omitted for brevity

Eliminate redundant planes from each R yielding

i

In the full version of this pap er we demonstrate

R

i

how for problems of any reasonable practical size we

Recursively solve the halfspace intersection problem

can improve up on this algorithm by using samples of

on each set R

i size instead of N The result is an algorithm that

2

has asymptotic IO p erformance of O log but

is far simpler to implement than Algorithm and

Algorithm An algorithm for computing the d

convex hull of a set of p oints will generally p erform b etter in practice The main

reason for the increase in p erformance is that to do

p olling eciently the algorithm requires see

rithm for computing the intersection of all h S

i

and thus in most practical situations N

Step can b e completed with O log IOs by

making a linear pass through S for each sample as

Parallel and multilevel extensions

suggested by Knuth Step consists of recursive

calls that will b e considered later In Step we de

comp ose each S into cones using a plane sweep This

j

Up to this p oint our discussion has centered on the

takes O jS jB log jS jB IOs We then take a

j j

case where D and P As has b een men

random sample from S S for each S This takes

j j

tioned even in this restricted mo del the results pre

O log IOs Finally we solve a tree structured

sented here are of tremendous practical imp ortance

p oint lo cation problem on all elements of the sam

Our results are even more signicant however b e

ple This is done by batch ltering as describ ed in

cause the paradigms describ ed in this pap er continue

Section The numb er of IO op erations needed by

to work even when parallelism is added and D and P

P

r r

Step is O jR j In Step log where r

i

i

B B

increase Furthermore they can b e made to work op

redundant planes are eliminated using a variant of the

timally on hierarchical mo dels having more than two

d maxima algorithm from Section and a d convex

levels these include the well known HMM BT

r r

log IO op era hull algorithm Both require O

B B

and UMH pictured in Figure and their paral

tions Finally Step recursively solves the subprob

lelizations pictured in Figure

lems

Details of the algorithms for these mo dels are dis

By metho ds analogous to the approach of Reif and

cussed in the full version of this pap er To a large

Sen for the parallel case we can develop the fol

extent they are based on mo died versions of two of

lowing recurrence for the running time of our algo

the main paradigms discussed ab ove namely distribu

rithm

tion sweeping and batch ltering We can also rely on

X

the manyway divideandconquer approach of Atallah

T jR j T n O log T N log

i

and Tsay which can b e extended to the IO mo del

i

To implement distribution sweeping in these mo dels

The rst term on the righthand side is the IO cost we take advantage of deterministic distribution tech

for sampling and partitioning the second term is the niques recently develop ed by No dine and Vitter

IO cost for sorting the samples and the last term is for optimal deterministic sorting To implement batch

for the recursive calls In the recurrence the jS j terms

ltering we can use disk striping i H            (a) (b) (c)

}

Figure Multilevel hierarchy mo dels a The HMM mo del access to memory lo cation x takes f x time We

ypical access functions like f x lg x and f x x for constant b The BT mo del access to the

consider t CPU CPU CPU CPUCPU CPU

memory lo cations x x x takes f x time c The UMH mo del

Nevertheless there are a numb er of interesting

problems that remain op en

Is there a data structure for d online range

queries that achieves O log IOs for up

“The Net” B

dates and range queries using O blo cks of

space The oline version of the problem is

solved optimally in this pap er Up dates and

threesided range queries can b e handled by

metablo ck trees in O log log B IOs

B

using O space Twosided range queries an

chored on the diagonal can b e done in O log

B

2

IOs p er query and O log log B

B B

IOs p er semidynamic insert

Can an N vertex p olygon b e triangulated using

O N B IOs Under what conditions

Can we nd all intersecting pairs of N non

orthogonal segments using O log IOs

Figure Parallel multilevel memory hierarchies The

H hierarchies of any of the typ es listed in Figure

References

have their base levels connected by H interconnected

A Aggarwal B Alp ern A K Chandra M Snir

pro cessors

A Mo del for Hierarchical Memory Pro c th ACM

STOC New York NY

Conclusion

A Aggarwal A Chandra M Snir Hierarchi

cal Memory with Blo ck Transfer Pro c th IEEE

FOCS Los Angeles CA We have given a numb er of paradigms for external

memory computational geometry that yield the rst

A Aggarwal J S Vitter The inputoutput com

known IO optimal algorithms for several interesting

plexity of sorting and related problems Comm ACM

largescale problems in computational geometry Be

cause they are simple and practical b oth on currently

B Alp ern L Carter E Feig T Selker The Uni

common systems P D and the parallel IO

form Memory Hierarchy Mo del of Computation Pro c

st IEEE FOCS St Louis MO To app ear in

systems likely to replace them in the not to o distant

Algorithmica

future we are convinced that the metho ds will gain widespread use

D G Kirkpatrick R Seidel The ultimate planar M J Atallah J J Tsay On the Parallel

convex hull algorithm SIAM J Comput Decomp osabil ity of Geometric Problems Algorith

mica

D E Knuth The Art of Vol R Bayer E McCreight Organization of large or

ume Seminumerical Algorithms Addison Wesley dered indexes Acta Informatica

Reading MA

B Chazelle L J Guibas Fractional Cascading I I

R Laurini D Thompson Fundamentals of Spatial Applications

Information Systems APIC Series Academic Press

B Chazelle L J Guibas Fractional Cascading I

New York NY

A Data Structuring Technique Algorithmica

N B Maginnis Store More Sp end Less Mid

Range Options Around Computerworld Novemb er

D Comer The ubiquitous Btree Comput Surveys

D Maier S C Salveter Hysterical Btrees In

R F Cromp An Intellegent Information Fusion

form Pro cess Lett

System for Handling the Archiving and Querying of

M H No dine J S Vitter Deterministic distribu Terabytesized Spatial Databases in Rep ort on the

tion sort in shared and distributed memory Multipro Workshop on Data and Image Compression Needs and

cessors Pro c th ACM SPAA Uses in the Scientic Community S R Tate ed

CESDIS Technical Rep ort Series TR CESDIS

D A Patterson G Gibson R H Katz A case for

redundant arrays of inexp ensive disks RAID Pro c

ACM SIGMOD J R Driscoll N Sarnak D D Sleator R E Tar

jan Making data structures p ersistent J Comput

F P Preparata S J Hong Convex hulls of nite

System Sci

sets of p oints in two and three dimensions Comm

ACM G Gibson L Hellerstein R M Karp R H Katz D

A Patterson Co ding Techniques for Handling Fail

F P Preparata M I Shamos Computational Ge

ures in Large Disk Arrays U C Berkeley UCBCSD

ometry An Intro duction SpringerVerlag New York

Decemb er

Heidelb ergBerl in

D Giord A Sp ector The TWA Reservation Sys

J R Reif S Sen Optimal parallel randomized algo

tem Comm ACM July

rithms for threedimensiona l convex hulls and related

problems SIAM J Comput M H Go o drich Geometric partioning made easier

even in parallel Pro c th ACM Comp Geo San

H Samet The Design and Analysis of Spatial Data

Diego CA

Structures Addison Wesley Reading MA

M T Go o drich Constructing the convex hull of a

H Samet Application s of Spatial Data Structures

partially sorted set of p oints Computational Geome

Computer Graphics Image Pro cessing and GIS Ad

try Theory and Applications

dison Wesley Reading MA

R L Graham An ecient algorithm for determining

R Tamassia J S Vitter mentioned in invited pap er

the convex hull of a nite planar set Inform Pro cess

by J S Vitter Ecient memory access in largescale

Lett

computation STACS Hamburg February

L J Guibas J Stol Primitives for the manip

R Tamassia J S Vitter Optimal Co op erative

ulation of general sub divisi ons and the computation

Search in Fractional Cascaded Data Structures Pro c

of Voronoi diagrams ACM Trans Graphics

nd ACM SPAA

University of California at Berkeley Massive Infor

W Jilke Disk Array Mass Storage Systems The New

mation Storage Management and Use NSF Insti

Opp ortunity Amp erif Corp oration Septemb er

tutional Infrastructure Prop osal Technical Rep ort

No UCBCSD January P C Kanellakis G M Kup er P Z Revesz Con

straint query languages Pro c th ACM PODS

J S Vitter E A M Shriver Optimal disk IO

with parallel blo ck transfer Pro c nd ACM STOC

Baltimore MD To app ear in Algorithmica P C Kanellakis S Ramaswamy D E Vengro J

S Vitter Indexing for Data Mo dels with Constraints

S B Zdonik D Maier eds Readings in Ob ject

and Classes Pro c th ACM PODS Washington

Oriented Systems Morgan Kauman

DC

R M Karp Probabili sti c recurrence relations Pro c

rd ACM STOC New Orleans LA