Geometric Applications of A Matrix Se~ching Algorithm Alok Aggarwal 1 Maria M. Klawe 2 Shlomo Moran 1'4 Peter Shor 3 Robert WIlber 2 1. IBM T. J. Watson Center, Yorktown Heights 2. IBM Almaden Research Center, San Jose 3. Math. Sciences Research Institute, Berkeley 4. On leave from The Technion, Haifa, Israel. I. Introduction
points in the plane. In fact, using some geometric properties of a convex polygon and the fact that any point can be the nearest neighbor of at most six
The all-farthest neighbor problem for a set of n points in the plane, P, is to find for each point Pie P,
other points in the plane, Lee and Preparata (LP78)
another point pj~ P with j # i such that
obtained a O(n) algorithm for the all-nearest neighbor problem on a convex polygon. However, since
d(Pi, pj)
-
max
l 1 and j >
and . 4 I ' i + 1 . . . . .
the
n;j, .... m]
T h e o r e m 3.1: Let A be an n x m m a t r i x , w h e r e n is
submatrices
(when i < n
a p o w e r of 2.
1)
e= 1 orm.
and
L e t h be a positive integer and let
Setf=m+
1-e.
Suppose that up to
m a x ( m -- 2, 0) cells h a v e already been queried (i.e.,
j < m). T h e time required b y this algorithm is given
h a v e been assigned fixed values).
by the r e c u r r e n c e
Also, suppose
that no cells h a v e been queried in A f, that a n y cells f(n,m)
< m + max
that h a v e been queried in A e h a v e been set to h, and
If(rn/21 - l,j) + 1)},
l r 2 a n d j =
• o t h e r w i s e set A (i, j ) t o h + 1. 2)
If i < r 2 a n d
j#
N o t e t h a t L satisfies t h e c o n d i t i o n s of t h e t h e o -
1 o r if i > r 2 a n d j # m ,
set
r e m , w i t h p a r a m e t e r s h t a n d e t, w h e r e e ~ = 1 a n d hr=hife=
A (i, l ) t o a l o w v a l u e .
landh'-h+
life=m.
Similarly, R
satisfies t h e c o n d i t i o n s of t h e t h e o r e m , w i t h p a r a m W h e n t h e first s t a g e e n d s , e x a c t l y m - 1 cells of A have been queried and the values fixed are cons i s t e n t w i t h all m a x i m a b e i n g in c o l u m n
1 and
in r o w s 1 t h r o u g h r 2 - 1 all m a x i m a
in r o w s r 2
t h r o u g h n b e i n g in c o l u m n m. Q u e r i e d cells in c o l umns 2 through m -
e t e r s h " a n d e", w h e r e e " = m - c + 1 a n d h " = h if e=mandh'=h+ queries
life=
of cells w i t h i n
1. I n t h e s e c o n d s t a g e L or R are handled
by
recursively applying the adversary strategy to the t w o s u b m a t r i c e s , a n d q u e r i e s t o cells o u t s i d e of L a n d R a r e a n s w e r e d in s u c h a w a y t h a t t h e y i m p o s e
1 all h a v e v a l u e s less t h a n 1.
n o c o n s t r a i n t s u p o n t h e p o s i t i o n s of t h e m a x i m a w i t h i n L o r R. A f t e r t h e first s t a g e is c o m p l e t e d a c o l u m n c a n d t w o s u b m a t r i c e s L a n d R a r e s e l e c t e d as f o l l o w s . T h e r u l e s f o r a n s w e r i n g a q u e r y of cell A (id) a r e
F o r 0 _< j < m, let sj b e t h e n u m b e r of q u e r i e d cells in c o l u m n s 1 t h r o u g h j of A (s o = 0).
Let c be the
as f o l l o w s .
s m a l l e s t i n t e g e r in [ 1, m ] s u c h t h a t sc = c - 1 ( t h e r e is s u c h a n i n t e g e r b e c a u s e S,n = m - 1 ). U s i n g t h e
1) If i < k 1 a n d j = 1, o r if i > k 4 a n d j = m, t h e n s e t
A ( i , j ) t o h + 1.
a c t t h a t t h e sj's a r e a n o n d e c r e a s i n g s e q u e n c e of int e g e r s it is e a s y t o s h o w b y i n d u c t i o n t h a t f o r a l l j in
2) I f k 2 < i < k
3andj=cthensetA(i,j)
toh+2.
[0, c - 1 ], sj > j. I n p a r t i c u l a r , s c_ 1 > c - 1. S i n c e Sc-1