\documentclass[portrait]{seminar}
\usepackage{amssymb}
\usepackage{epsfig}
\usepackage{fancybox}
\usepackage[dvips]{color}
\slidesmag{2.3}
\definecolor{Defn}{rgb}{0,0.7,0}
\definecolor{Ex}{rgb}{0,0.7,0}
\definecolor{Rem}{rgb}{0,0.7,0}
\definecolor{Eqn}{rgb}{0,0,0.7}
\definecolor{Thm}{rgb}{1.0,0,0}
\definecolor{Head}{rgb}{0,0,1.0}
\definecolor{subHead}{rgb}{0,0.7,0}
\definecolor{emph}{rgb}{1.0,0,0}
\definecolor{ciamac}{rgb}{0.7,0.4,0}

%\renewcommand{\printlandscape}{\special{landscape}}

%\newcommand{\bottomline}{\makebox[0cm][l]{Peter McNamara} \hfil \theslide \hfil \makebox[0cm] [r]{MIT}}
\newcommand{\bottomline}{\hfill \theslide \hfill}
\newpagestyle{All}{}{\bottomline}
%\newpagestyle{All}{\textcolor{ciamac}{Primera Conferencia Iberoamericana de Matem\'atica Computacional}\hfill}{\bottomline}

\newcommand{\heading}[1]{%
  \begin{center}
    \large\bf
    \shadowbox{\textcolor{Head}{#1}}%
  \end{center}
  \vspace{5mm}}


\newcommand{\subheading}[1]{%
  \begin{center}
    \large\bf
    \doublebox{\textcolor{subHead}{#1}}%
  \end{center}
  \vspace{5mm}}



\newenvironment{Thm}{\noindent\textcolor{Thm}{\textsc{Theorem}}\slshape}{}
\newenvironment{Cor}{\noindent\textsc{Corollary}\slshape}{}
\newenvironment{Prop}{\noindent\textsc{Proposition}\slshape}{}
\newenvironment{Defn}{\noindent\textcolor{Defn}{\textbf{Definition}}\rmfamily}{}
\newenvironment{Rem}{\noindent\textcolor{Rem}{\textbf{Remark\ }}\rmfamily}{}
\newenvironment{Ex}{\noindent\textcolor{Ex}{\textsc{Example\ }}\rmfamily}{}

\newenvironment{Proof}
{\begin{description}\item[Proof ]}{{\unskip\nobreak\raggedleft\hfill$\square$}\end{description}}
  

\newcommand{\binomial}[2]{\left({\displaystyle #1} \atop {\displaystyle #2}\right)}
\newcommand{\binomialp}[2]{\left({#1} \atop {#2}\right)}

\newcommand{\desc}[2]{\begin{description}\item[{#1}]\ \ {#2} \end{description}\vspace{3mm}}
\newcommand{\m}{\mathfrak{m}}


\begin{document}

\begin{slide*}
\begin{center}

\textcolor{Head}{\textsl{The Closest Pair Problem, Deterministic and Randomized Algorithms}}
\newline
\newline
\newline
\newline
Rado\v s Radoi\v ci\'c
\\

\vspace{1cm}
\color{subHead}
6.838J Computational Geometry \\
20th November 2001\\
%\color{black}
%\vfill
%Slides available from
%
%\texttt{http://www-math.mit.edu/$\sim$rados/}
%
\end{center}
\end{slide*}


\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Motivation, Notation and Definitions}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item 

\begin{Defn} \emph{\textcolor{emph}{The closest pair problem}}

Given a set $S$ of $n$ points in $\mathbb{R}$$^{D}$, find a closest pair of $S$, i.e. two points $P$ and $Q$ such that $$d(P, Q) = \mbox{min}\{d(p, q) : p, q \in S, p \neq q\}.$$

The distance $d(P, Q)$ is called the \emph{minimal distance} of $S$, and will also be denoted by $d(S)$.

\end{Defn}

\vspace*{1cm}

\item If $p \in \mathbb{R}^{D}$, then $d(p, S)$ denotes the minimum distance from $p$ to any point of $S\backslash \{p\}$.  

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Applications}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item Geometric proximity problems have numerous applications in computational geometry, statistics, pattern recognition, molecular biology, etc.

\vspace*{.1in}

\item Shamos' and Rabin's papers dealing with the closest pair problem are considered to be seminal papers in computational geometry and randomization.

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Trivial Observations}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item Can be trivially solved in $O(Dn^2)$ times.  

\vspace*{.1in}

\item \emph{\textcolor{emph}{Did we see this problem before?}}

We have already seen something similar for $D = 2$ in Problem 3 on PS 2:

Use the Voronoi diagram to solve a strong generalization of the closest pair problem, known as \emph{\textcolor{emph}{the all-nearest-neighbor problem}}: 

Compute for each point $p$ of $S$ another point of $S$ that is closest to $p$. 

\vspace*{.1in}

\item \emph{\textcolor{emph}{Reminder}} : This approach is not good for $D > 2$.  Voronoi diagrams have linear complexity only in $D = 2$.  In $\mathbb{R}$$^{D}$, the combinatorial complexity of Voronoi diagrams can be $\Omega (n^{\lceil D/2 \rceil})$.

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Algorithms presented today}}
\end{center}

\vspace{1cm}

We will obtain:

\begin{enumerate}

\item A randomized algorithm of Khuller and Matias, running in expected $O(n)$ time, in any fixed dimension $D$.  

\vspace{1cm}

\item A deterministic algorithm of Bentley and Shamos, using the divide-and-conquer paradigm and running in $O(n(\log{n})^2)$ time, in any fixed dimension $D$.

\vspace{1cm}

\item An incremental randomized algorithm of Golin et al, running in expected $O(n)$ time, in any fixed dimension $D$.

\vspace{1cm}

\noindent \emph{\textcolor{emph}{Note}}: The deterministic algorithm of Bentley and Shamos is supposed to be optimal in the algebraic computation tree model, but we were not able to shave off an extra $\log{n}$ factor.  All the constants within the $O$ asymptotics are more or less of the form $D^D$. 

\end{enumerate}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Sparseness Lemma}}
\end{center}

\vspace{1cm}

\begin{Prop}
Let $S$ be a set of $n$ points in $\mathbb{R}$$^{D}$, and let $c$ be a positive integer.  Then any $D$-dimensional cube having sides of length $c\cdot d(S)$ contains at most $(cD + c)^D$ points of $S$.
\end{Prop}

\begin{Proof}
By contradiction, using the standard packing argument.  Assume that the cube contains more than $(cD + c)^D$ points of $S$.  Partition the cube into $(cD + c)^D$ subcubes with sides of length $c\cdot d(S)/(cD + c)$.  Then one of these subcubes contains at least two points of $S$.  The distance between these points is at most equal to the $L_1$-diameter of the subcube, which is equal to $Dc\cdot d(S)/(cD + c) < d(S)$.  This is a contradiction.
\end{Proof}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Additional Definitions}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item If $\delta$ is a positive real number, then a $\delta$-\emph{grid} is the subdivision of $\mathbb{R}^{D}$ into axes-parallel cells with sides of length $\delta$, defined by hyperplanes $x_i = j\delta$, where $1 \leq i \leq D$ and $j$ ranges over all integers.  

\vspace*{1cm}

\item \emph{The neighborhood of a cell} is defined as the cell itself plus the $3^D - 1$ cells that border it.  

\emph{The neighborhood of a point} $p$, denoted by $N(p)$ is defined as the neighborhood of the cell containing $p$.

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Sieve Closest Pair Algorithm (Khuller and Matias)}}
\end{center}

\vspace{1cm}

\emph{\textcolor{emph}{Idea}}:  Iteratively \emph{filter} the points of $S$, i.e. discard points that are known to be ``far away'' from all other points.  Achieve a good approximation of $d(S)$, and then find the exact value.

\begin{itemize}

\item \textbf{Step 0.}  Initialize $i := 1$, $S_1 := S$.
\item \textbf{Step 1.}  Choose a random point $x_i \in S_i$ and compute $d(x_i, S_i)$, which we also denote by $d_i$. 
\item \textbf{Step 2.}  Construct the $\delta$-grid, where $\delta = d_i/4D$.  Let $A_i$ be the set of all points of $S_i$ that are alone in their neighborhoods.  Set $S_{i+1} = S_i \backslash A_i$.
\item \textbf{Step 3.}  If $S_{i+1} \neq \emptyset$, then $i : = i + 1$, and GOTO \textbf{Step 1.}  Otherwise, let $l := i$ and GOTO \textbf{Step 4.} 
\item \textbf{Step 4.}  Construct a $\delta-grid$ where $\delta := d_l$.  For every point in $S$, compute the distance to the closest point to $x$ in $N(x)$.  Find a closest pair by computing the minimum over all these distances.

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Proof of Correctness I}}
\end{center}

\vspace{1cm}

\emph{\textcolor{emph}{Goal}}: Once we reach \textbf{Step 4}, we have an approximation for $d(S)$ within a constant factor.\\
\\
Consider the $i$-th iteration.  Let $p \in S_i$.  The following properties are trivial: 
\begin{itemize}
\item \textbf{Property 1.}  If $d(p, S_i) \leq d_i/4D$, then there exists a point in $S_i$ which is in $N(p)$ and, thus, $p \in S_{i+1}$.

\item \textbf{Property 2.}  If $d(p, S_i) > d_i/2$, then $N(p)$ is empty and, thus, $p \notin S_{i+1}$.

\end{itemize}

\noindent Now, we can show that sets $S_i$ \emph{decrease geometrically}.

\begin{Prop} $d_{i+1} \leq d_i/2.$ \end{Prop}

\begin{Proof} Let $x_{i+1}$ be the point selected from $S_{i+1}$ in the $(i+1)$-st iteration.  Since $x_{i+1} \in S_{i+1}$, there exists a point $y\in S_i$ such that $y \in N(x_{i+1})$, in the $d_i/4D$-grid.  Then $d(x_{i+1}, y) \leq d_i/2$.  Clearly, $y \in S_{i+1}$, since $x_{i+1} \in N(y)$ in the $d_i/4D$-grid.  So, $d_{i+1} = d(x_{i+1}, S_{i+1}) \leq d(x_{i+1}, y) \leq d_i/2.$  

\end{Proof} 

\noindent Therefore, the grids become finer and finer as we iterate.

\begin{Cor} $\{d_i\}_{i \geq 1}$ is decreasing. \end{Cor}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Proof of Correctness II}}
\end{center}

\vspace{1cm}

\begin{Prop} $d_l/4D \leq d(S) \leq d_l$. \end{Prop}

\begin{Proof} 
The right inequality is trivial, since $d_l$ is a distance in $S$. 

Let $P$ and $Q$ be the points of the closest pair in $S$.  Let $i$ and $j$ be the indices such that $P\in S_i\backslash S_{i+1}$ and $Q\in S_j\backslash S_{j+1}$.  WLOG assume that $i < j$.  

Then $Q \in S_i$ and, thus, $d(S) = d(P, Q) = d(P, S_i)$.

By \textbf{Property 1} we know that $d(P, S_i) > d_i/4D$ (otherwise, $P \in S_{i+1}$). 

Therefore, $d(S) > d_i/4D \geq d_l/4D$, where the last inequality follows from the previous corollary.

\end{Proof}

Thus, at the end of the ``filtering'' stage we have a good approximation for $d(S)$.

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Computing $d(S)$ from its approximation $d(x_l)$}}
\end{center}

\vspace{1cm}

\noindent In \textbf{Step 4}:

\begin{itemize}

\item We build a $d(x_l)$-grid and for each nonempty cell we build a list of all the points in this cell.

\item This can be done using perfect hashing of Fredman, Koml\'os and Szemer\'edi in $O(|S|) = O(n)$ expected time.  

\item For each point $x$ we find the distance to its closest point in $N(x)$, if such a point exists.  By the \textbf{Sparseness Lemma}, or by a standard volume argument, $N(x)$ contains at most a constant number of points.  So, this can be done in $O(1)$ time per point of $S$.

\item The minimum over all these distances is $d(S)$, since for each point of a closest pair, the other point is in its neighborhood.

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Running Time}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item \textbf{Step 4} takes $O(n)$ expected time.

\item 
\begin{Prop} The ``filtering'' stage takes $O(n)$ expected time. \end{Prop}

\begin{Proof}

\begin{itemize}
\item The cost of the $i$-th iteration is $O(|S_i|)$, if using a membership structure that can answer queries in $O(1)$ time, such as perfect hashing.

\item We need to show that the sizes $s_i$ of the sets $S_i$ are expected to decrease $(s_{l+1} = s_{l+2} = \ldots = s_{n} = 0)$.

\item If $r \in S_i$ is such that $d(r, S_i) \geq d_i$, then by \textbf{Property 2} $r\notin S_{i+1}$.

\item Take the points in $S_i$ and label them $r_1, r_2, \cdots, r_k$, so that $d(r_1, S_i) \leq d(r_2, S_i) \leq \cdots \leq d(r_k, S_i)$.

\item The point $x_i$ is chosen randomly from the set $S_i$, so it can be any $r_j$ with equal probability.

\item $E(|S_{i+1}| | |S_i| = k) \leq k/2.$   

\item $E(s_{i+1}) \leq s_i/2.$

\item $E(s_{i+1}) = E(E(s_{i+1})) \leq E(s_i/2) = \frac{1}{2}E(s_i).$

\item By induction on $i$, $E(s_{i}) \leq \frac{n}{2^{i-1}}.$

\item By linearity of expectation, 
$$E(\sum_{i=1}^{l} |S_i|) \leq E(\sum_{i=1}^{n} s_i) = \sum_{i=1}^{n} E(s_i) \leq \sum_{i=1}^{n} n/2^{i-1} \leq 2n.$$

\end{itemize}

\end{Proof}

\item The randomized sieve algorithm of Khuller and Matias takes $O(n)$ expected time.

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Deterministic Divide-and-Conquer Algorithm in $\mathbb{R}$$^{2}$}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item \emph{Preprocessing stage:} Sort the points by their $x$-coordinates in the $x$-array and by their $y$-coordinates in the $y$-array.  

\vspace*{.1in}

\item \textbf{Step 1.} Find a vertical line $H$ that bisects the point set $S$ into two sets $S_L$ and $S_R$, each with approximately half the points. 

\vspace*{.1in}

\item \textbf{Step 2.} Recursively, find the closest pair in $S_L$ and in $S_R$.  Let the minimal distances in $S_L$ and $S_R$ be $\delta_L$ and $\delta_R$ respectively, and let $\delta = \mbox{min}(\delta_R, \delta_L)$.

\vspace*{.1in}

\item \emph{Note} It suffices to check points of $S$ that are at most $\delta$ away from the separating line $H$.  Thus:

\textbf{Step 3.} Scan the points in the $y$-aray and discard all points that are more than $\delta$ away from the vertical line $H$.  

The remaining points are already sorted by the $y$-coordinate and reside in the vertical strip of width $2\delta$ around the line $H$.  

We refer to this list of points as the \emph{updated} $y$-array.

\vspace*{.1in}

\item \textbf{Step 4.}  For each point $v$ in the updated $y$-array, consider the points immediately preceeding/following $v$ in the array (with larger/smaller $y$-coord's) that are at most $\delta$ away from it.  

For each point $v$ in the updated $y$-array, there are at most $12$ such points that are in the $2\delta$ vertical strip ({\bf Next slide}).  

Compute the distances from $v$ to these points and find the minimal distance.  

Take the minimum of this distance and $\delta$.  

\end{itemize}

\end{slide*}
\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{At Most $12$ points Can Fit}}
\end{center}

\vspace{1cm}

\begin{Prop}  For any point $v$ in the $2\delta$ vertical strip, there are at most $12$ points whose distance from $v$ is no more than $\delta$. \end{Prop}

\begin{Proof}

\begin{itemize}

\item For each point $v$ in the $2\delta$ vertical strip, consider a square of side length $2\delta$, such that $v$ is on the line bisecting the square horizontally, and the line $H$ bisects the square vertically.

\begin{figure}
\center
\epsfxsize=55mm
\epsfbox{closest1.eps}
\end{figure}

\item Any pair of points which are on the same side of $H$ must be at least $\delta$ apart.  One easily finds that there are no more than $12$ points which reside within this square.

\end{itemize}

\end{Proof}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Running Time}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item \textbf{Step 1} takes $O(1)$ time (do not forget that the points are pre-sorted).

\item \textbf{Step 2} takes $2T(n/2)$ time.

\item \textbf{Step 3} takes $O(n)$ time.

\item \textbf{Step 4} involves $O(1)$ amount of computation per point, and thus takes $O(n)$ time.

\vspace*{.2in}

\item Thus, $$T(n) \leq 2T(n/2) + O(n),$$ which gives $T(n) = O(n\log{n})$.

Pre-processing does not affect the running time.

\end{itemize}

\vspace*{.2in}

\emph{\textcolor{emph}{Question: What about $d \geq 3$?}}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Divide-and-Conquer in Higher Dimensions}}
\end{center}

\vspace{1cm}

\emph{\textcolor{emph}{Idea}}:  We try to generalize the previous algorithm for $d \geq 2$, by iterating the divide-and-conquer paradigm.  

Let $T(n, d)$ denote the running time of our algorithm.

\vspace{1cm}

\emph{\textcolor{emph}{CLOSEST-PAIR(S)}}

\begin{itemize}

\item \emph{Preprocessing Stage:}  Assume that $S$, $|S| = n$, is sorted w.r.t. each of the $d$ coordinates.  This can be done in $O(dn\log{n}) = O(n\log{n})$ time.

\item \textbf{Step 1.}  Find a median hyperplane $H$ perpendicular to some axis which partitions $S$ into 2 subsets $S_1$ and $S_2$ of aproximately equal size.  This can be accomplished in $O(n)$ time. 
 
\item \textbf{Step 2.}  Recursively find the closest pair for each subset, and let $\delta = \mbox{min}(\delta_1, \delta_2)$, where $\delta_i$ denotes the minimal distance for $S_i$.  This step takes $2T(n/2, d)$ time.

\item \textbf{Step 3.}  Throw out points in $S$ which are further than distance $\delta$ from the separating hyperplane $H$.  Let $S'$ denote the set of points not thrown out, and let $|S'| = m$.  Also, define $S'_1$ and $S'_2$ as the remaining points of $S_1$ and $S_2$.  This step takes $O(dn) = O(n)$ time.

\item \textbf{Step 4.}  Find the closest pair in $S'$ such that one point of the pair is in each of the sets $S'_i$, and return smaller of $\delta$ and the distance separating this pair.  

\emph{\textcolor{emph}{Question:  How do we design the last step?}}

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Step 4 of the Algorithm}}
\end{center}

\vspace{1cm}

We need the following observations:

\begin{Prop} Let $p_i$ be any point of $S'$, $i = 1, \ldots, m$.  Then the $d$-dimensional cube $C_i$ centered at $p_i$ of side $\delta$ contains $O(4^{d}) = O(1)$ points. 
\end{Prop}

\begin{Proof}  A standard volume argument with packing balls of radius $\delta/2$ in $C_i$. 
\end{Proof}

\vspace{1cm}

\begin{Prop} Suppose we project $S'$ onto the separating hyperplane $H$.  Then the cubes $C_i$ are projected onto $(d-1)$-dimensional cubes $C'_i$, and, furthermore, a given point $p$ of $S'$ is in $C_i$ if and only if its projection is in $C'_i$.  
\end{Prop}

\vspace{1cm}

\emph{\textcolor{emph}{Suppose}} that we have a procedure, which we will call \textbf{SPARSE}, that for every $p_i$ in $S'$, outputs its $(d-1)$-dimensional cube $C'_i$.  Then in \textbf{Step 4} of \emph{\textcolor{emph}{CLOSEST-PAIR(S)}}, we do the following:

\begin{enumerate}

\item For each point $p_i$ in $S'$, find all points in $C_i$.  By the proposition, these are exactly the projection pre-images of the points in $C'_i$ returned by \textbf{SPARSE($S'$, $\delta$)}.

\item Find the distances from $p_i$ to every point in its cube $C_i$.  By the proposition, there are $O(m)$ distances to check.  Choose the smallest of these distances and find the minimum over all points $p_i$.  This takes $O(m)$ time. 

\item Return the minimum of this distance and $\delta$.

\end{enumerate}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The SPARSE Procedure}}
\end{center}

\vspace{1cm}

\textbf{SPARSE} is passed $\delta$ and a set $S$ of $m$ points in $\mathbb{R}$$^{d-1}$ and must find the subcubes $C'_i$  for each of the points.  Let $T'(m, d-1)$ denote the running time of {\bf SPARSE}.

\vspace{1cm}

\textbf{SPARSE($S$, $\delta$)}

\begin{enumerate}

\item Partition the set $S$ of $m$ points into $2$ subsets of roughly equal cardinality using a median hyperplane perpendicular to one of the axis.  Recursively find the subcubes of each point, entirely on one side of the separating hyperplane.  This step takes $2T'(m/2, d-1)$ time.

\item Throw out all points outside the $2\delta$-slab surrounding the separating hyperplane, and let $m'$ be the number of points remaining.

\item Project the remaining points onto the separating hyperplane and recurse on their projections.  From the propositions on the previous slide, we know that the cubes returned by this recursive call will be exactly those desired.  This recursive call takes $T'(m', d - 2)$ time.

\item Combine the recursively obtained sub-solutions and return the answer in $O(m)$ time.  
  
\end{enumerate}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Overall Running Time of the Algorithm}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item  \textbf{SPARSE} runs in time $T'(m, d-1)$, satisfying the following recurrence:
$$T'(m, d-1) \leq 2T'(m/2, d-1) + T'(m', d-2) + O(m),$$
where $m' \leq m$.  This recurrence gives 
$$T'(m, d-1) = O(m(\log{m})^{d-1}).$$

\vspace{1cm}

\item  Since \textbf{SPARSE($S'$, $\delta$)} takes $O(m(\log{m})^{d-1})$ time, we conclude that:
$$T(n, d) \leq 2T(n/2, d) + T'(m, d-1) + O(m) \leq $$
$$\leq 2T(n/2, d) + O(m(\log{m})^{d-1}) + O(m),$$ 
where $m \leq n$.  This implies that the running time of \emph{\textcolor{emph}{CLOSEST-PAIR(S)}} is $$T(n, d) = O(n(\log{n})^{d-1}).$$ 

\end{itemize}
 
\vspace{1cm}

\emph{\textcolor{emph}{QUESTION:  Can we reduce the time complexity?}}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Efficient-SPARSE Procedure}}
\end{center}

\vspace{1cm}

The following \textbf{Theorem} will help us improve the time complexity of our algorithm.

\vspace*{.2in}

\begin{Thm} Given any set $S$ of $n$ points in $\mathbb{R}$$^{d}$, and given $\delta > 0$, there exists a hyperplane $H$, perpendicular to one of the coordinate axes, with the following properties:
\begin {enumerate}
\item There are at least $n/4d$ points on either side of $H$.
\item The $2\delta$-thick slab, whose width is perpendicularly bisected by $H$ has at most $d\alpha n^{1-1/d}$ points in it, where $\alpha = O(4^d)$.
\end{enumerate}
\end{Thm}

\vspace*{.2in}

\emph{\textcolor{emph}{Main Idea}}: \textbf{Efficient-SPARSE} works just like \textbf{SPARSE}, except that the separating hyperplane is chosen more carefully, according to the \textbf{Theorem} above.

\vspace*{.2in}

\textbf{Efficient-SPARSE($S$, $\delta$)} first chooses a hyperplane $H$ in $\mathbb{R}$$^{d-1}$, which satisfies conditions of the Theorem above.  

In other words, there are at least $\frac{n}{4(d-1)}$ points of $S$ on either sides of $H$ and the $2\delta$-thick slab around $H$ has at most $n' = (d-1)\alpha n^{1-1/(d-1)}$ points of $S$.  

This can be done in $O((d-1)n)$ time, as it will be shown {\bf Later}.  

Next, it makes the same recursive calls on the two ``halves'' of the partition (each of size $\geq n/4(d-1)$), and on the projections of the $n'$ points within distance $\delta$ of the separating hyperplane.

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Running Times of Efficient-SPARSE and the Overall Algorithm}}
\end{center}

\vspace{1cm}

\noindent
The running time $T''(n, d-1)$ of {\bf Efficient-SPARSE($S$, $\delta$)} procedure satisfies: 
$$T''(n, d-1) \leq T''(\beta n, d-1) + T''((1-\beta)n, d-1) + T''(n', d-2) + O(n), $$
where $\frac{1}{4(d-1)} \leq \beta \leq 1-\frac{1}{4(d-1)}$, and $n' \leq (d-1)\alpha n^{1-1/(d-1)}$.  This implies
$$T''(n, d-1) = O(n\log{n}).$$

\vspace{1cm}

\noindent
The running time of the overall algorithm, using {\bf Efficient-SPARSE($S'$, $\delta$)} procedure instead of {\bf SPARSE($S'$, $\delta$)}, becomes:

$$T(n, d) \leq 2T(n/2, d) + T''(m, d-1) + O(m) \leq $$
$$\leq 2T(n/2, d) + O(m\log{m}) + O(m) \leq 2T(n/2, d) + O(n\log{n}) + O(n),$$
since $m \leq n$.  

This implies $$T(n, d) = O(n(\log{n})^2).$$

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Proof of the Theorem I}}
\end{center}

\vspace{1cm}

\noindent For simplicity, let's consider only $d = 2$ case.
Suppose the theorem's statement is false for some set $S$ of $n$ points in $\mathbb{R}$$^{2}$.  Then, 
\vspace*{.2in}
\begin{itemize}

\item Partition the plane by placing vertical and horizontal lines at distance $2\delta$ from each other, where $n/8$ points lie to the left of the leftmost line, and right of the rightmost line.  

\item Say there are $k$ vertical slabs.  We have $k\alpha \sqrt{n} \leq 3n/4$, which gives $k \leq \frac{3}{4\alpha}\sqrt{n}$.

\item Similarly, we partition the plane with horizontal lines, and for the number $l$ of horizontal slabs we obtain $l \leq \frac{3}{4\alpha}\sqrt{n}$.

\begin{figure}
\center
\epsfxsize=75mm
\epsfbox{closest2.eps}
\end{figure}

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{Proof of the Theorem II}}
\end{center}

\vspace{1cm}

\begin{itemize}

\item By the \emph{sparseness}, the number of points in any square with side $2\delta$ is some constant $c$.  Thus, the number of points inside all slabs is at most $c\cdot k\cdot l \leq (\frac{3}{4\alpha})^2c\cdot n$.

\item Since there are $\geq n/2$ points inside the slabs, this is a contradiction if we choose $\alpha \geq \frac{\sqrt{18c}}{4}$.

\item One of these $k$ vertical or $l$ horizontal lines satisfies the desired properties.  

\end{itemize}

\vspace*{.2in}

\noindent Now, it is also clear how to find a hyperplane satisfying the conditions of \textbf{Theorem} in $O(n)$ time.  

In $d = 2$, we simply check these $k + l$ lines and choose the desired one, which exists by the Theorem.  

In general, we use the fact that $S$ is pre-sorted along each of the $d$ coordinates.

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Randomized Incremental Algorithm of Golin et al.}}
\end{center}

\vspace{1cm}

\noindent \emph{\textcolor{emph}{Randomized-Incremental($S$)}}

\begin{itemize}

\item Number the points of $S$ \emph{randomly} $p_1, p_2, \ldots, p_n$.  For $2 \leq i \leq n$, let $S_i := \{p_1, \ldots, p_i\}$.  

\item The algorithm computes $d(S_2), d(S_3), \ldots, d(S_n),$ in this order.  Also, let $P$ and $Q$ denote the points of a closest pair in the current set considered.

\item Initialize $d(S_2) := d(p_1, p_2)$ and $(P, Q) := (p_1, p_2)$.  Store $S_2$ in a $d(S_2)$-grid.

\item Assume that $d(S_i)$ has been computed already and that $S_i$ is stored in a $d(S_i)$-grid (using perfect hashing).  Also, assume that $(P, Q)$ is a closest pair of $S_{i}$.  

\item To compute $d(S_{i+1})$ we do the following (we are adding $p_{i+1}$ to the current set):

\begin{enumerate}

\item Let $h := \mbox{min}\{d(p_{i+1}, q): q \, \mbox{is in the neighborhood of} \, \mbox{the cell of}\, p_{i+1}\}$.  We find this distance by brute force, using perfect hashing.  By \textbf{Sparseness Lemma}, there is at most constant number of points to check in this neighborhood.

\item If $h < d(S_i)$, then let $q$ be a point in $S_i$ such that $d(p_{i+1}, q) = h$.  Set $(P, Q) := (p_{i+1}, q)$ and $d(S_{i+1}) := h$.  Discard the $d(S_i)$-grid and store all points of $S_{i+1}$ in a \emph{new} $d(S_{i+1})$-grid.  

\item Otherwise, set $d(S_{i+1}) := d(S_i)$ and add $p_{i+1}$ to the $d(S_{i+1})$-grid (which is the \emph{old} $d(S_i)$-grid).  

\end{enumerate}

\item After $n - 1$ iterations, output $(P, Q)$ and $d(S_n)$.

\end{itemize}

\end{slide*}

\begin{slide*}\slidepagestyle{All}
\begin{center}
\textcolor{subHead}{\textsl{The Running Time}}
\end{center}

\vspace{1cm}

\noindent In the \emph{worst case}, we have to build a new grid, during each iteration, leading to a quadratic running time.  However, the expected running time is only linear.  We use \emph{\textcolor{emph}{backward analysis}}!

\begin{itemize}

\item We run the algorithm \emph{backwards}.  One iteration can be viewed as picking a random point $p$ of $S_{i+1}$, deleting it and possibly ``dismantling'' the current grid.  

\end{itemize}

\noindent There are three possible cases:

\begin{itemize}

\item Point $p$ is not part of any closest pair of $S_{i+1}$, or $S_{i+1}$ also contains a closest pair $p$ is not part of. 

The current grid is not dismantled when deleting $p$.  Hence, the iteration takes $O(1)$ expected time.

\item Set $S_{i+1}$ contains several closest pairs which all contain the point $p$.  

The removal of $p$ increases the minimum distance and, thus, the current grid is dismantled.  This takes $O(i + 1)$ expected time. 

Since $p$ is a random point, this happens with probability $1/(i+1)$.

Therefore, this iteration takes $O(1)$ expected time.

\item Set $S_{i+1}$ contains exactly one closest pair and $p$ is a part of it. 

The removal of $p$ increases the minimum distance and, thus, the current grid is dismantled.  This takes $O(i + 1)$ expected time. 

Since $p$ is a random point, this happens with probability $2/(i+1)$.

Therefore, this iteration takes $O(1)$ expected time.

\end{itemize}

\noindent \emph{\textcolor{emph}{Conclusion}}:  This algorithm takes linear expected time.  It can be shown that w.h.p. the running time is $O(n\log{n}/\log{\log{n}}).$

\end{slide*}

\end{document}

