---
abstract: |
    We revisit a classical problem in computational geometry: finding the largest-volume axis-aligned empty box (inside a given bounding box) amidst $n$ given points in $d$ dimensions. Previously, the best algorithms known have running time $O(n\log^2n)$ for $d=2$ (by Aggarwal and Suri \[SoCG'87\]) and near $n^d$ for $d\ge 3$. We describe faster algorithms with running time

    -   $O(n2^{O(\log^*n)}\log n)$ for $d=2$,

    -   $O(n^{2.5+o(1)})$ time for $d=3$, and

    -   $\widetilde{O}(n^{(5d+2)/6})$ time for any constant $d\ge 4$.

    To obtain the higher-dimensional result, we adapt and extend previous techniques for Klee's measure problem to optimize certain objective functions over the complement of a union of orthants.
author:
- 'Timothy M. Chan[^1]'
bibliography:
- 'opt\_box\_arxiv.bib'
title: Faster Algorithms for Largest Empty Rectangles and Boxes
---

Introduction
============

#### Two dimensions.

In the first part of this paper, we tackle the *largest empty rectangle* problem: Given a set $P$ of $n$ points in the plane and a fixed rectangle $B_0$, find the largest rectangle $B\subset B_0$ such that $B$ does not contain any points of $P$ in its interior. Here and throughout this paper, a "rectangle" refers to an axis-parallel rectangle; and unless stated otherwise, "largest" refers to maximizing the area.

The problem has been studied since the early years of computational geometry. While similar basic problems such as largest empty circle or largest empty square can be solved efficiently using Voronoi diagrams, the largest empty rectangle problem seems more challenging. The earliest reference on the 2D problem appears to be by Naamad, Lee, and Hsu in 1984 @Naa, who gave a quadratic-time algorithm. In 1986, Chazelle, Drysdale, and Lee @ChDrLe obtained an $O(n\log^3 n)$-time algorithm. Subsequently, at SoCG'87, Aggarwal and Suri @AggSur presented another algorithm requiring $O(n\log^3n)$ time, followed by a more complicated second algorithm requiring $O(n\log^2n)$ time. The $O(n\log^2n)$ worst-case bound has not been improved since.[^2]

A few results on related questions have been given. Dumitrescu and Jiang @DumJia examined the combinatorial problem of determining the worst-case number of maximum-area empty rectangles and proved an $O(n2^{\alpha(n)}\log n)$ upper bound; their proof does not appear to have any implication to the algorithmic problem of finding a maximum-area empty rectangle. If the objective is changed to maximizing the perimeter, the problem is a little easier and an optimal $O(n\log n)$-time algorithm can already be found in Aggarwal and Suri's paper @AggSur. Another related problem of computing a maximum-area rectangle contained in a polygon has also been explored @DaMiRo.

We obtain a new randomized algorithm that finds the maximum-area empty rectangle in $O(n2^{O(\log^*n)} \log n)$ expected time. This is not only an improvement of almost a full logarithmic factor over the previous 33-year-old bound, but is also close to optimal, except for the slow-growing iterated-logarithmic-like factor (as $\Omega(n\log n)$ is a lower bound in the algebraic decision tree model).

Our solution interestingly uses *interval trees* to efficiently divide the problem into subproblems of logarithmic size, yielding a recursion with $O(\log^*n)$ depth.

#### Higher dimensions.

The higher-dimensional analog of the problem is *largest empty box*: Given a set $P$ of $n$ points in ${\mathbb{R}}^d$ and a fixed box $B_0$, find the largest box $B\subset B_0$ such that $B$ does not contain any points of $P$ in its interior. Here and throughout this paper, a "box" refers to an axis-parallel hyperrectangle; and unless stated otherwise, "largest" refers to maximizing the volume.

Several papers @DumJia13 [@DumJia; @DumJia16; @Ull] have studied related questions in higher dimensions, e.g., proving combinatorial bounds on the number of optimal boxes, or proving extremal bounds on the volume, or designing approximation algorithms. For the original (exact) computational problem, it is not difficult to obtain an algorithm that finds the largest empty box in ${\widetilde{O}}(n^d)$ time (for example, as was done by Backers and Keil @BacKei).[^3] At the end of their SoCG'16 paper, Dumitrescu and Jiang @DumJia explicitly asked whether a faster algorithm is possible:

> "Can a maximum empty box in ${\mathbb{R}}^d$ for some fixed $d\ge 3$ be computed in $O(n^{\gamma_d})$ time for some constant $\gamma_d < d$?"

Dumitrescu and Jiang attempted to give a subcubic algorithm for the 3D problem, but their conditional solution required a sublinear-time dynamic data structure for finding the 2D maximum empty rectangles containing a query point—currently, the existence of such a data structure is not known.

On the lower bound side, Giannopoulos, Knauer, Wahlström, and Werner @Gia proved that the largest empty box problem is $W[1]$-hard with respect to the dimension. This implies a conditional lower bound of $\Omega(n^{\beta d})$ for some absolute constant $\beta>0$, assuming a popular conjecture on the hardness of the clique problem.

We answer the above question affirmatively. For $d=3$, we give an $O(n^{5/2+{\varepsilon}})$-time algorithm, where ${\varepsilon}>0$ is an arbitrarily small constant. For higher constant $d\ge 4$, we obtain an algorithm with an intriguing time bound that improves over $n^d$ even more dramatically: ${\widetilde{O}}(n^{(5d+2)/6})$. For example, the bound is $O(n^{3.667})$ for $d=4$, ${\widetilde{O}}(n^{4.5})$ for $d=5$, and $O(n^{8.667})$ for $d=10$.

Not too surprisingly, our 3D algorithm achieves subcubic complexity by applying standard range searching data structures (though the application is not be immediately obvious). Dynamic data structures are not used.

The techniques for our higher-dimensional algorithm are perhaps more original and significant, with potential impact to other problems. We first transform the largest empty box problem into a problem about a union of $n$ orthants in $D=2d$ dimensions (the transformation is simple and has been exploited before, such as in @Bar). The union of orthants is known to have worst-case combinatorial complexity $O(n^{{\left\lfloor D/2\right\rfloor}})$ @Boi. Interestingly, we show that it is possible to maximize certain types of objective functions over the complement of the union, in time significantly smaller than the worst-case combinatorial complexity.

We accomplish this by adapting known techniques on Klee's measure problem @OveYap [@ChaSoCG08; @Bri; @ChaFOCS13]. Specifically, we build on a remarkable method by Bringmann @Bri for computing the volume of a union of $n$ orthants in $D$ dimensions in $O(n^{D/3+O(1)})$ time (the $O(1)$ term in the exponent was $2/3$ but has been later removed by author @ChaFOCS13). However, maximizing an objective function over the complement of the union is different from summing or integrating a function, and Bringmann's method does not immediately generalize to the former (for example, it exploits subtraction). We introduce extra ideas to extend the method, which results in a bigger time bound than $n^{D/3}=n^{2d/3}$ but nevertheless beats $n^{D/2}=n^d$. In particular, we use some simple graph-theoretical arguments, applied to graphs with $O(D)$ vertices.

#### Paper organization.

We present our 2D algorithm in Section \[sec:2d\], our 3D algorithm in Section \[sec:3d\], and our higher-dimensional algorithms in Sections \[sec:anchored\]–\[sec:box\] (all these parts may be read independently).

<span>Largest Empty Rectangle in 2D</span> {#sec:2d}
==========================================

As in previous work @ChDrLe [@AggSur], we focus on solving a *line-restricted* version of the 2D largest empty rectangle problem: given a set $P$ of $n$ points below a fixed horizontal line $\ell_0$ and a set $Q$ of $n$ points above $\ell_0$, where the $x$-coordinates of all points have been pre-sorted, and given a rectangle $B_0$, find the largest-area rectangle $B\subset B_0$ that intersects $\ell_0$ and is empty of points of $P\cup Q$. By standard divide-and-conquer, an $O(T(n))$-time algorithm for the line-restricted problem immediately yields an $O(T(n)\log n)$-time algorithm for the original largest empty rectangle problem, assuming that $T(n)/n$ is nondecreasing. We begin by reformulating the line-restricted problem as a problem about horizontal line segments. In the subsequent subsections, we will work with this re-formulation.

For each point $p\in P$, let $s(p)$ be the longest horizontal line segment inside $B_0$ such that $s(p)$ passes through $p$ and there are no points of $P$ above $s(p)$. See Figure \[fig:cart\](a). We can compute $s(p)$ for all $p\in P$ in $O(n)$ time: this step is equivalent to the construction of the standard *Cartesan tree* @Vui [@GaBeTa], for which there are simple linear-time algorithms (for example, by inserting points from left to right and maintaining a stack, like Graham's scan, as also re-described in previous papers @ChDrLe [@AggSur]). Similarly, for each $q\in Q$, let $t(q)$ be the longest horizontal line segment inside $B_0$ such that $t(q)$ passes through $q$ and there are no points of $Q$ below $t(q)$. We can also compute $t(q)$ for all $q\in Q$ in $O(n)$ time.

![(a,b) Transforming points into horizontal segments. (c) Pseudo-ray ${\makebox[0pt]{\raisebox{5.5pt}{\tiny\ \ \ $\leftarrow$}}\gamma}_s$.<span data-label="fig:cart"></span>](fig_cartesian.pdf)

For a horizontal segment $s$, let $x_s^-$ and $x_s^+$ denote the $x$-coordinates of its left and right endpoints respectively, and let $y_s$ denote its $y$-coordinate. We say that a set $S$ of horizontal segments is *laminar* if for every $s,s'\in S$, either the two intervals $[x_s^-,x_s^+]$ and $[x_{s'}^-,x_{s'}^+]$ are disjoint, or one interval is contained in the other (in other words, the intervals form a "balanceded parentheses" or tree structure). It is easy to see that for the segments defined above, $\{s(p):p\in P\}$ is laminar and $\{t(q):q\in Q\}$ is laminar.

The optimal rectangle must have some point $p^*\in P$ on its bottom side and some point $q^*\in Q$ on its top side (except when the optimal rectangle touches the bottom or top side of $B_0$, a case that can be easily dismissed in linear time). Chazelle, Drysdale, and Lee @ChDrLe already noted that the case when $[x^-_{s(p^*)},x^+_{s(p^*)}]$ is contained in $[x^-_{t(q^*)},x^+_{t(q^*)}]$ can be handled in $O(n)$ time (in their terminology, this is the case of "three supports in one half, one in the other").[^4] The key remaining case is when $x_{t(q^*)}^- < x_{s(p^*)}^- < x^+_{t(q^*)} < x^+_{s(p^*)}$, where the area of the optimal rectangle is $(x^+_{t(q^*)} - x_{s(p^*)}^-)(y_{t(q^*)}-y_{s(p^*)})$. All other cases are symmetric. The problem is thus reduced to the following (see Figure \[fig:cart\](b)):

\[prob1\] Given a laminar set $S$ of $n$ horizontal segments and a laminar set $T$ of $n$ horizontal segments, where all $x$-coordinates have been pre-sorted, find a pair $(s,t)\in S\times T$ such that $x_t^- < x_s^- < x_t^+ < x_s^+$, maximizing $(x_t^+ - x_s^-)(y_t-y_s)$.

We find it more convenient to work with the corresponding *decision problem*, as stated below. By the author's randomized optimization technique @ChaSoCG98, an $O(T(n))$-time algorithm for Problem \[prob2\] yields an $O(T(n))$-expected-time algorithm for Problem \[prob1\], assuming that $T(n)/n$ is nondecreasing:

\[prob2\] Given a laminar set $S$ of $n$ horizontal segments and a laminar set $T$ of $n$ horizontal segments, where all $x$-coordinates have been pre-sorted, and given a value $r>0$, decide if there exists a pair $(s,t)\in S\times T$ such that $x_t^- < x_s^- < x_t^+ < x_s^+$ and $(x_t^+ - x_s^-)(y_t-y_s) > r$, and if so, report one such pair. We call such a pair *good*.

Preliminaries
-------------

To help solve Problem \[prob2\], we define a curve $\gamma_s$ for each $s\in S$: $$\gamma_s(x) = \left\{\begin{array}{ll}
\frac{r}{x-x_s^-} + y_s & \mbox{if $x\ge x_s^-+\delta$}\\
M +x_s^-  & \mbox{if $x < x_s^-+\delta$,}
\end{array}\right.$$ for a sufficiently small $\delta>0$ and a sufficiently large $M=M(\delta)$. (The main first part of the curve is a hyperbola.) The condition $(x_t^+ - x_s^-)(y_t-y_s) > r$ is met iff the point $(x_t^+,y_t)$ (i.e., the right endpoint of $t$) is above the curve $\gamma_s$, assuming $x_t^+\ge x_s^- +\delta$. Note that these curves form a family of *pseudo-lines*, i.e., every pair of curves intersect at most once: this can be seen from the fact that for any two curves $\gamma_s$ and $\gamma_{s'}$ with $x_s^-\ge x_{s'}^-$, the difference $\gamma_{s}(x)-\gamma_{s'}(x) = \tfrac{r(x_{s}^- - x_{s'}^-)}{(x-x_s^-)(x-x_{s'}^-)} + y_s - y_{s'}$ is nonincreasing for $x\ge x_s^-$.

Define the curve segment ${\makebox[0pt]{\raisebox{5.5pt}{\tiny\ \ \ $\leftarrow$}}\gamma}_s$ to be the part of $\gamma_s$ restricted to $x\le x_s^+$. (See Figure \[fig:cart\](c).) These curve segments form a family of *pseudo-rays*. The lower envelope of $n$ pseudo-rays has at most $2n$ edges, by known combinatorial bounds on order-2 Davenport-Schinzel sequences @ShaAgaBOOK. The following lemma summarizes known subroutines we need on the computation of lower envelopes (proofs are briefly sketched).

\[lem:LE\] Consider a set of $n$ pseudo-lines, sorted by their *pseudo-slopes*, such that if $\gamma$ and $\gamma'$ intersects and $\gamma$ has smaller pseudo-slope, then $\gamma$ is above $\gamma'$ to the left of the intersection. Assume that the intersection of any two pseudo-lines can be computed in constant time.

1.  \[(a)\] Consider $n$ pseudo-rays that are parts of the given pseudo-lines, such that the $x$-coordinates of the left endpoints are all $-\infty$, and the $x$-coordinates of the right endpoints are monotone (increasing or decreasing) in the pseudo-slopes. Then the lower envelope of these pseudo-rays can be computed in $O(n)$ time.

2.  \[(b)\] Consider $n$ pseudo-segments that are parts of the given pseudo-lines, such that $x$-coordinates of the left endpoints are monotone in the pseudo-slopes and the $x$-coordinates of the right endpoints are monotone in the pseudo-slopes. Then the lower envelope of these pseudo-segments can be computed in $O(n)$ time.

Part (a) follows by a straightfoward variant of Graham's scan @BerBOOK (originally for computing planar convex hulls, or by duality, lower envelopes of lines). We insert pseudo-rays in decreasing order of their right endpoints' $x$-values, while maintaining the portion of the lower envelope to the left of the right endpoint of the current pseudo-ray. In each iteration, by the monotonicity assumption, a prefix or suffix of the lower envelope gets deleted (i.e., popped from a stack).

For part (b), the main case is when both the left and right endpoints are monotonically increasing in the pseudo-slopes (the case when both are monotonically decreasing is symmetric, and the case when they are monotone in different directions easily reduces to two instances of the pseudo-ray case). Greedily construct a minimal set of vertical lines that stab all the pseudo-segments: namely, draw a vertical line at the leftmost right endpoint, remove all pseudo-segments stabbed, and repeat. This process can be done in $O(n)$ time by a linear scan. These vertical lines divide the plane into slabs. (See Figure \[fig:fifo\].) In each slab, the pseudo-segments behave like pseudo-rays, so we can compute the lower envelope inside the slab in linear time by applying part (a) twice, for the leftward rays and for the rightward rays (the two envelopes can be merged in linear time). Since each pseudo-segment participates in at most two slabs, the total time is linear.

![Proof of Lemma \[lem:LE\](b): the $x$-projected intervals and the division into slabs.<span data-label="fig:fifo"></span>](fig_fifo.pdf)

As an application of Lemma \[lem:LE\](b), we mention an efficient algorithm for a special case of Problem \[prob2\], which will be useful later.

\[cor\] In the case when all segments in $S$ and $T$ intersect a fixed vertical line, Problem \[prob2\] can be solved in $O(n)$ time.

Since $S$ and $T$ are laminar, the $x$-projected intervals in each set are nested. Let $s_1,s_2,\ldots$ be the segments in $S$ with $[x^-_{s_1},x^+_{s_1}]\subseteq [x^-_{s_2},x^+_{s_2}]\subseteq\cdots$, and let $t_1,t_2,\ldots$ be the segments in $T$ with $[x^-_{t_1},x^+_{t_1}]\subseteq [x^-_{t_2},x^+_{t_2}]\subseteq\cdots$. For each $s_i$, let $a(i)$ be the smallest index with $x_{t_{a(i)}}^- <  x_{s_i}^-$, let $b(i)$ be the smallest index with $x_{s_i}^- < x_{t_{b(i)}}^+$, and let $c(i)$ be the largest index with $x_{t_{c(i)}}^+ < x_{s_i}^+$. Note that $a(i)$ is monotonically increasing in $i$, and $b(i)$ is monotonically decreasing in $i$, and $c(i)$ is monotonically increasing in $i$. It is straightforward to compute $a(i),b(i),c(i)$ for all $i$ by a linear scan.

The problem reduces to finding a pair $(s_i,t_j)$ such that $\max\{a(i),b(i)\}\le j\le c(i)$ and the right endpoint of $t_j$ is above $\gamma_{s_i}$. Define the curve segment ${\overline{\gamma}}_{s_i}$ to be the part of $\gamma_{s_i}$ restricted to $x\in [\max\{x_{t_{a(i)}}^+,x_{t_{b(i)}}^+\}, x_{t_{c(i)}}^+]$. The problem reduces to finding a $t_j$ whose right endpoint is above some curve segment ${\overline{\gamma}}_{s_i}$, i.e., above the lower envelope of these curve segments. We can compute this lower envelope in $O(n)$ time by Lemma \[lem:LE\](b) (more precisely, by two invocations of the lemma, as $\max\{x_{t_{a(i)}}^+,x_{t_{b(i)}}^+\}$ consists of a monotonically increasing and a monotonically decreasing part). The problem can be then be solved by linear scan over the envelope and the endpoints of $t_j$.

Algorithm
---------

We are now ready to describe our new algorithm for solving Problem \[prob2\], using interval trees and an interesting recursion with $O(\log^*n)$ depth.

Problem \[prob2\] can be solved in $O(n2^{O(\log^*n)})$ time.

As a first step, we build the standard *interval tree* for the given horizontal segments in $S\cup T$. This is a perfectly balanced binary tree of with $O(\log n)$ levels, where each node corresponds to a vertical slab. The root slab is the entire plane, the slab at a node is the union of the slabs of its two children, and each leaf slab contains no endpoints in its interior. Each segment is stored in the lowest node $v$ whose slab contains the segment (i.e., the segment is contained in $v$'s slab but is not contained in either child's subslab). Note that each segment is stored only once (unlike in another standard structure called the "segment tree"). We can determine the slab containing each segment in $O(1)$ time by an LCA query @BenFar (which is easier in the case of a perfectly balanced binary tree).

For each node $v$, let $S_v$ (resp. $T_v$) be the set of all segments of $S$ (resp. $T$) stored in $v$. Define the *level* of a segment to be the level of the node it is stored in.

<span>Case 1:</span> there exists a good pair $(s^*,t^*)$ where $s^*$ and $t^*$ have the same level. Here, $s^*$ and $t^*$ must be stored in the same node $v$ of the interval tree. Thus, a good pair can be found as follows:

1.  For each node $v$, solve the problem for $S_v$ and $T_v$ by Corollary \[cor\] in $O(|S_v|+|T_v|)$ time. Note that all segments in $S_v\cup T_v$ indeed intersect a fixed vertical line (the dividing line at $v$).

The total running time of this step is $O(n)$, since each segment is in only one $S_v$ or $T_v$.

<span>Case 2:</span> there exists a good pair $(s^*,t^*)$ where $s^*$ is on a strictly lower level than $t^*$. To deal with this case, we perform the following steps, for some choice of parameter $b\ge \log n$:

1.  For each node $v$, compute the lower envelope of the pseudo-rays $\{{\makebox[0pt]{\raisebox{5.5pt}{\tiny\ \ \ $\leftarrow$}}\gamma}_s: s\in S_v\}$ by Lemma \[lem:LE\](a) in $O(|S_v|)$ time; let ${{\cal E}}_v$ denote this envelope restricted to $v$'s slab. Note that because all segments in $S_v$ intersect a fixed vertical line and $S_v$ is laminar, the $x_s^+$ values are monotonically decreasing in the $x_s^-$ values for $s\in S_v$ and so are indeed monotone in the pseudo-slopes of these pseudo-rays.

2.  Divide the plane into a set $\Sigma$ of $n/b$ vertical slabs each containing $b$ right endpoints of $T$.

3.  For each slab $\sigma\in \Sigma$,

    -   let $T_\sigma$ be the set of all segments $t\in T$ with right endpoints in $\sigma$, and

    -   let $S_\sigma$ be the set of all segments $s\in S$ such that ${\makebox[0pt]{\raisebox{5.5pt}{\tiny\ \ \ $\leftarrow$}}\gamma}_s$ appears on ${{\cal E}}_v\cap\sigma$ for some node $v$.

    Divide $S_\sigma$ (arbitrarily) into blocks of size $b$ and recursively solve the problem for $T_\sigma$ and each block of $S_\sigma$.

*Correctness.* Consider a good pair $(s^*,t^*)$ with $s^*$ on a strictly lower level than $t^*$. Let $\sigma$ be the slab in $\Sigma$ containing the right endpoint of $t^*$, i.e., $t^*\in T_\sigma$. Let $v$ be the node $s^*$ is stored in. Then $t^*$ intersects the left wall of the slab at $v$ (since $t^*$ must be stored in a proper ancestor of $v$). Now, the right endpoint of $t^*$ is below ${\makebox[0pt]{\raisebox{5.5pt}{\tiny\ \ \ $\leftarrow$}}\gamma}_{s^*}$ and is thus below ${{\cal E}}_v$. Let ${\makebox[0pt]{\raisebox{5.5pt}{\tiny\ \ \ $\leftarrow$}}\gamma}_{s}$ be the curve on ${{\cal E}}_v$ that the right endpoint of $t^*$ is below, with $s\in S_v$. Then ${\makebox[0pt]{\raisebox{5.5pt}{\tiny\ \ \ $\leftarrow$}}\gamma}_s$ appears on ${{\cal E}}_v\cap\sigma$, and so $s\in S_\sigma$. Since the right endpoint of $t^*$ is below ${\makebox[0pt]{\raisebox{5.5pt}{\tiny\ \ \ $\leftarrow$}}\gamma}_s$, we have $x_{s}^- < x_{t^*}^+ < x_{s}^+$, and since $t^*$ intersects the left wall of $v$'s slab, we have $x_{t^*}^- < x_{s}^-$. So, $(s,t^*)$ is good, and the recursive call for $T_\sigma$ and some block of $S_\sigma$ will find a good pair.

*Analysis.* The total number of edges in all envelopes ${{\cal E}}_v$ is at most $2\sum_v |S_v|\le 2n$. Since the envelopes ${{\cal E}}_v$ have disjoint $x$-projections for nodes $v$ at the same level, and since there are $O(\log n)$ levels, the $O(n/b)$ dividing vertical lines of $\Sigma$ intersect at most $O((n/b)\log n)$ edges among all the envelopes. Thus, $\sum_{\sigma\in\Sigma} |S_\sigma| \le 2n + O((n/b)\log n)=O(n)$ if $b\ge\log n$, and so the total number of recursive calls in step 2c is $O(n/b)$.

<span>Case 3:</span> there exists a good pair $(s^*,t^*)$ where $s^*$ is on a strictly higher level than $t^*$. This remaining case is symmetric to Case 2 (by switching $S$ and $T$ and negating $y$-coordinates).

By running the algorithms for all three cases, a good pair is guaranteed to be found if one exists. The running time satisfies the recurrence $T(n) \le O(n/b)T(b) + O(n)$. Setting $b=\log n$ gives $T(n)\le n2^{O(\log^*n)}$.

By the observations from the beginning of this section, we can now solve Problem \[prob1\] and the line-restricted problem in $O(n2^{O(\log^*n)})$ expected time, and the original largest empty rectangle problem in $O(n2^{O(\log^*n)}\log n)$ expected time.

Given $n$ points in ${\mathbb{R}}^2$ and a rectangle $B_0$, we can compute the maximum-area empty rectangle inside $B_0$ in $O(n2^{O(\log^*n)}\log n)$ expected time.

Largest Empty Box in 3D {#sec:3d}
=======================

In this section, we describe a subcubic algorithm for the largest empty box problem in 3D. The key is the following result on an "asymmetric" case with a left point set and right point set of different sizes:

Given a set $P$ of $n$ points in $(-\infty,0)\times {\mathbb{R}}^2$, and a set $Q$ of $m$ points in $(0,\infty)\times {\mathbb{R}}^2$, we can compute the maximum-volume box that contains the origin and is empty of points in $P\cup Q$ in ${\widetilde{O}}(n^2 + m^{4+{\varepsilon}})$ time for an arbitrarily small constant ${\varepsilon}>0$.

Map a box $b=(-x_1,x_1')\times (-x_2,x_2')\times
(-x_3,x_3')\subset {\mathbb{R}}^3$ to a point $b^*= (x_1,x_1',x_2,x_2',x_3,x_3')$ in 6D. Map a point $p=(p_1,p_2,p_3)\in {\mathbb{R}}^3$ to an orthant $p^* = (-p_1,\infty)\times (p_1,\infty)\times
(-p_2,\infty)\times (p_2,\infty)\times (-p_3,\infty)\times (p_3,\infty)$ in 6D. Then the point $p$ is in the box $b$ iff the point $b^*$ is in the orthant $p^*$.

Say $B_0=(-c_1,c_1')\times (-c_2,c_2)\times (-c_3,c_3)$. Define ${{\cal X}}= [0,c_1]\times [0,c_1']\times [0,c_2]\times [0,c_2']\times [0,c_3]\times [0,c_3']$.

Our goal is to find a point $b^*=(x_1,x_1',x_2,x_2',x_3,x_3')\in {{\cal X}}$ maximizing the function $H(b^*):=(x_1+x_1')(x_2+x_2')(x_3+x_3')$, such that $b^*$ is in the complement of both $U(P)=\bigcup_{p\in P} p^*$ and $U(Q)=\bigcup_{q\in Q} q^*$. Let $Z$ be the set of all vertices of $U(P)\cap{{\cal X}}$ and $A$ be the set of all vertices of $U(Q)\cap {{\cal X}}$. The constraint can then be restated as follows: $b^*$ is dominated by some vertex in $Z$ and by some vertex in $A$.

Since all points $(p_1,p_2,p_3)\in P$ have $p_1<0$, $U(P)\cap {{\cal X}}$ corresponds to a union of $n$ orthants in 5D (the second dimension is irrelevant); by known results on the union complexity of orthants @Boi, the set $Z$ has $O(n^2)$ size and can be constructed in ${\widetilde{O}}(n^2)$ time. Similarly, since all points $(q_1,q_2,q_3)\in Q$ have $q_1>0$, $U(Q)\cap {{\cal X}}$ corresponds to a union of $n$ orthants in 5D (the first dimension is irrelevant); the set $A$ has $O(m^2)$ size and can be constructed in ${\widetilde{O}}(m^2)$ time.

For each $z=(z_1,z_1',z_2,z_2',z_3,z_3')\in Z$ and each $a=(a_1,a_1',a_2,a_2',a_3,a_3')\in A$, the maximum of $h(b^*)$ over all $b^*\in {{\cal X}}$ that are dominated by both $z$ and $a$ is given by the function $$f(z,a) \: :=\: (\min\{z_1,a_1\} + \min\{z_1',a_1'\})\cdot
(\min\{z_2,a_2\} + \min\{z_2',a_2'\})\cdot
(\min\{z_3,a_3\} + \min\{z_3',a_3'\}).$$ Thus, our problem is reduced to computing the maximum of $f(z,a)$ over all $z\in Z$ and $a\in A$.

This new problem can be solved by standard range searching technique. First consider the decision problem of testing whether the maximum exceeds a given fixed value $r$. We build a two-level data structure for $A$ and ask a query for each $z\in Z$, to decide whether there exists an $a\in A$ with $f(z,a)\ge r$:

For each $z\in Z$, in one case, we identify all $a\in A$ with $z_1\ge a_1$, $z_1'\le a_1'$, $z_2\ge a_2$, $z_2'\le a_2'$, $z_3\ge a_3$, and $z_3'\le a_3'$, by orthogonal range searching (a range tree) @BerBOOK. The answer can be expressed as a union of ${\widetilde{O}}(1)$ canonical subsets $A_i$. For each such canonical subset $A_i$, we decide whether there exists an $a\in A_i$ with $(z_1 + a_1')(z_2 + a_2')(z_3 + a_3') \ge r$. This can be done by point location in a lower envelope of surfaces of the form $z_3 = \frac{r}{(z_1+a_1')(z_2+a_2')} - a_3'$ in 3D. By known results on lower envelopes of surfaces @Sha94, with $O(|A_i|^{2+{\varepsilon}})$-time preprocessing, a query can be answered in $O(\log m)$ time.

In another case, for example, when $z_1\ge a_1$, $z_1'\ge a_1'$, $z_2\ge a_2$, $z_2'\le a_2'$, $z_3\ge a_3$, and $z_3'\le a_3'$, we decide whether there exists an $a\in A_i$ with $(z_1 + z_1')(z_2 + a_2')(z_3 + a_3') \ge r$. With a change of variable $z_1''=z_1+z'$, this can be done by point location in a lower envelope of surfaces of the form $z_3 = \frac{r}{z_1''(z_2+a_2)}-a_3'$ in 3D. Other cases are similar (or easier).

The entire two-level data structure has $O(|A|^{2+{\varepsilon}})$ preprocessing time and ${\widetilde{O}}(1)$ query time. The total time for $|Z|$ queries is ${\widetilde{O}}(|A|^{2+{\varepsilon}}+|Z|) = {\widetilde{O}}(m^{4+O({\varepsilon})} + n^2)$.

The original problem can be reduced to the decision problem, for example, by the author's randomized optimization technique @ChaSoCG98, or deterministically, by parametric search @Meg (since the preprocessing algorithm can be parallelized).

Given $n$ points in ${\mathbb{R}}^3$ and a box $B_0$, we can compute the maximum-volume empty box inside $B_0$ in $O(n^{5/2+{\varepsilon}})$ time for an arbitrarily small constant ${\varepsilon}>0$.

By divide-and-conquer, it suffices to solve the *plane-restricted* version where the box is constrained to intersect a given axis-parallel plane. By another application of divide-and-conquer, the problem can be further reduced to the *line-restricted* version when the box is constrained to intersect a given axis-parallel line $\ell_0$. The running time increases by at most two logarithmic factors. Without loss of generality, assume that $\ell_0$ is the first coordinate axis.

Divide space into $n/m$ slabs, by planes orthogonal to the first coordinate axis, where each slab contains $m$ points. Order the slabs from left to right. Let $Q_i$ be the subset of all input points in the $i$-th slab $\sigma_i$.

Consider the case when the optimal box has its right side in $\sigma_i$ but is not contained in $\sigma_i$. This case reduces to an instance of the above lemma for the two point sets $Q_1\cup\cdots \cup Q_{i-1}$ and $Q_i$ (after translation to make the left wall of $\sigma_i$ pass through the origin). The total cost over all $n/m$ slabs $\sigma_i$ is thus ${\widetilde{O}}((n/m)\cdot (n^2 + m^{4+{\varepsilon}}))$. Setting $m=\sqrt{n}$ gives a time bound of $O(n^{5/2+{\varepsilon}})$.

The remaining case when the optimal box is contained in $\sigma_i$ for some $i$ can be handled by recursion. The total time is $T(n)=\sqrt{n}T(\sqrt{n}) + O(n^{5/2+{\varepsilon}})$, yielding $T(n)=O(n^{5/2+{\varepsilon}})$. (Alternatively, instead of recursion, we could switch to some known cubic algorithm.)

In higher dimensions $d\ge 4$, a similar approach can yield an algorithm with running time of the form $O(n^{d-1+O(1/d)})$, but the approach in Section \[sec:box\] is better. On the other hand, for $d=3$, the algorithm in Section \[sec:box\] gives time bound ${\widetilde{O}}(n^{(5d+2)/6})={\widetilde{O}}(n^{17/6})$, which is worse than $n^{5/2}$.

<span>Largest Empty Anchored Box in Higher Dimensions<span>\
</span> (Warm-Up)</span> {#sec:anchored}
============================================================

To prepare for our solution to the largest empty box problem in higher constant dimensions, we first investigate a simpler variant, the *largest empty anchored box* problem: given a set $P$ of $n$ points in ${\mathbb{R}}^d$ and a fixed box $B_0$, find the largest-volume anchored box in $B_0$ that does not contain any points of $P$ in its interior, where an *anchored* box has the form $B=(0,x_1)\times\cdots (0,x_d)$ (having the origin as one of its vertices).

Let $\bigcup S$ denote the union of a set $S$ of objects. By mapping a box $B=(0,x_1)\times\cdots (0,x_d)$ to the point $(x_1,\ldots,x_d)$, and mapping each input point $(p_1,\ldots,p_d)$ to the orthant $(p_1,\infty)\times\cdots\times (p_d,\infty)$, the largest empty anchored box problem reduces to:

\[prob:anchored\] Define the function ${H_{\mbox{\scriptsize\rm vol}}}(x_1,\ldots,x_d)=x_1x_2\cdots x_d$. Given a set $S$ of $n$ orthants in ${\mathbb{R}}^d$ and a box $B_0$, find the maximum of ${H_{\mbox{\scriptsize\rm vol}}}$ over $B_0 - \bigcup S$.

<span> (In the application to largest empty anchored box, the orthants all contain $(\infty,\ldots,\infty)$, but our algorithm does not require all orthants to be of the same type.) </span>

By known results @Boi, the union of $n$ orthants in ${\mathbb{R}}^d$ has worst-case combinatorial complexity $O(n^{{\left\lfloor d/2\right\rfloor}})$ and can be constructed in ${\widetilde{O}}(n^{{\left\lfloor d/2\right\rfloor}})$ time. We will show that Problem \[prob:anchored\] can be solved faster than explicitly constructing the union.

Preliminaries
-------------

A key tool we need is a spatial partitioning scheme due to Overmars and Yap @OveYap (originally developed for solving Klee's measure problem in ${\widetilde{O}}(n^{d/2})$ time). The version stated below is taken from @ChaFOCS13 [Lemma 4.6]; see that paper for a short proof. (The partitioning scheme is also related to "orthogonal BSP trees" @DuMiSh [@ChaLee].)

\[lem:bsp\] Given a set of $n$ axis-parallel flats (of possibly different dimensions) in ${\mathbb{R}}^d$, and given a parameter $r$, we can divide ${\mathbb{R}}^d$ into $O(r^d)$ cells (bounded and unbounded boxes) so that each cell intersects $O(n/r^{j})$ $(d-j)$-flats. The construction of the cells, along with the conflict lists (lists of all flats intersecting each cell), can be done in ${\widetilde{O}}(n+r^d+K)$ time,[^5] where $K$ is the total size of the conflict lists.

Call a function $H:{\mathbb{R}}^d\rightarrow {\mathbb{R}}$ *simple* if it has the form $$H(x_1,\ldots, x_d)\ =\  h_1(x_1)\cdots h_d(x_d),$$ where each $h_i$ is a univariate step function. The *complexity* of $H$ refers to the total complexity (number of steps) in these step functions. As an illustration of the usefulness of Lemma \[lem:bsp\], we first how to maximize simple functions over the complement of a union of orthants in ${\widetilde{O}}(n^{d/2})$ time:

\[lem1:anchored\] Let $H$ be a simple function with $O(n)$ complexity. Given a set $S$ of $n$ orthants in ${\mathbb{R}}^d$ and a box $B_0$, we can compute the maximum of $H$ in $B_0-\bigcup S$ in ${\widetilde{O}}(n^{d/2})$ time for any constant $d\ge 2$.

Apply Lemma \[lem:bsp\] to the $O(n)$ $(d-2)$-flats that pass through the $(d-2)$-faces of the given orthants. This yields a partition of $B_0$ into cells.

Consider a cell ${\Delta}$. The number of $(d-2)$-flats intersecting ${\Delta}$ is bounded by $O(n/r^2)$, which can be made 0 by setting $r:=\Theta(\sqrt{n})$. Consequently, only $(d-1)$-faces of the given orthants may intersect ${\Delta}$, i.e., all orthants are 1-sided inside ${\Delta}$. The union of 1-sided orthants simplifies to the complement of a box (we can use orthogonal range searching or intersection data structure to identify the 1-sided orthants intersecting ${\Delta}$ and compute this box in ${\widetilde{O}}(1)$ time @AgaEriSURV [@BerBOOK]). For a simple function $H(x_1,\ldots,x_d)=h_1(x_1)\cdots h_d(x_d)$, we can maximize $H$ over a box by maximizing $h_i(x_i)$ over an interval for each $i\in\{1,\ldots,d\}$ separately. This corresponds to a 1D range maximum query for each $i$, which can be done straightforwardly in $O(\log n)$ time (or more carefully in $O(1)$ time @BenFar). As the number of cells is $O(r^d)=O(n^{d/2})$, the total running time is ${\widetilde{O}}(n^{d/2})$.

Algorithm
---------

To improve over $n^{d/2}$, we adapt an approach by Bringmann @Bri (originally for solving Klee's measure problem for orthants in $O(n^{d/3+O(1)})$ time). The approach involves first solving the 2-sided special case, and then applying Overmars and Yap's partitioning scheme. A *2-sided orthant* is the set of all points $(x_1,\ldots,x_d)\in{\mathbb{R}}^d$ satisfying a condition of the form $[x_i\ ?\ a]\wedge [x_j\ ?\ b]$ for some $i,j\in\{1,\ldots,d\}$, where each occurrence of "?" is either $\le$ or $\ge$. We will adapt the author's subsequent re-interpretation @ChaFOCS13 [Section 4.1] of Bringman's technique, described in terms of monotone step functions.

![The union of one type of 2-sided orthants.<span data-label="fig:staircase"></span>](fig_staircase.pdf)

\[thm0:anchored\] In the case when all the input orthants are 2-sided, Problem \[prob:anchored\] can be solved in ${\widetilde{O}}(n^{{\left\lfloor d/2\right\rfloor}/2})$ time for any constant $d\ge 4$.

The boundary of the union of 2-sided orthants of the form $[x_i\ ?\ a]\wedge [x_j\ ?\ b]$ with a fixed $i,j$ and a fixed choice for the two "?"s is a staircase, i.e., the graph of a univariate monotone (increasing or decreasing) step function. (See Figure \[fig:staircase\].) Thus, the complement of the union of 2-sided orthants can be expressed as the set of all points $(x_1,\ldots,x_d)\in{\mathbb{R}}^d$ satisfying an expression $E(x_1,\ldots,x_d)$ which is a conjunction of $O(d^2)$ predicates each of the form $[x_i\ ?\ f(x_j)]$, where $i,j\in\{1,\ldots,d\}$, "?" is $\le$ or $\ge$, and $f$ is a monotone step function. The total complexity of these step functions is $O(n)$. Conversely, any such expression can be mapped back to the complement of a union of $O(n)$ 2-sided orthants.

We first observe a few simple rules for rewriting expressions:

1.  $[x_i \le f(x_j)]\wedge [x_i \le g(x_j)]$ can be rewritten as $[x_i\le \min\{f,g\}(x_j)]$ if $f$ and $g$ are both increasing or both decreasing. Note that the lower envelope $\min\{f,g\}$ is still a monotone step function with $O(n)$ complexity. A similar rule applies for $\ge$.

2.  $[x_i\le f(x_j)]$ can be rewritten as $[x_j\ge f^{-1}(x_i)]$ if $f$ is increasing (the inequality is flipped if $f$ is decreasing). Note that the inverse $f^{-1}$ is still a monotone step function.

3.  More generally, $[f(x_i)\le g(x_j)]$ can be rewritten as $[x_j\ge (f^{-1}\circ g)(x_i)]$ if $f$ is increasing (the inequality is flipped if $f$ is decreasing). Note that the composition $f^{-1}\circ g$ is still a monotone step function with $O(n)$ complexity.

4.  $[x_i\le f(x_j)]\wedge [x_i\le g(x_k)]$ can be rewritten as the disjunction of $[x_i\le f(x_j)] \wedge [f(x_j)\le g(x_k)]$ and $[x_i\le g(x_k)] \wedge [g(x_k)\le f(x_j)]$. A similar rule applies for $\ge$.

The plan is to decrease the dimension by repeatedly eliminating variables: We maintain a simple function $H$. Initially, $H(x_1,\ldots,x_d)=\sigma(x_1)\cdots\sigma(x_d)$, where $\sigma(x)$ denotes the successor of $x$ among the $O(n)$ input coordinate values ($\sigma$ is a step function). We call an index $i$ *free* if the variable $x_i$ appears exactly once in $H$ and is "unaltered", i.e., $h_i(x_i)=\sigma(x_i)$. All indices are initially free.

In each iteration, we pick a free index $i$. Whenever $x_i$ appears more than twice in $E$, we can apply rule 4 (in combination with rules 1–3) to obtain a disjunction of 2 subexpressions, where in each subexpression, the number of occurrences of $x_i$ is decreased. By repeating this process $O(1)$ times (recall that $d$ is a constant), we obtain a disjunction of $O(1)$ subexpressions, where in each subexpression, only at most two occurrences of $x_i$ remain—in at most one predicate of the form $[x_i\le f(x_j)]$, and at most one predicate of the form $[x_i\ge g(x_k)]$. We branch off to maximize $H$ over each of these subexpressions separately. In such a subexpression, to eliminate the variable $x_i$ while maximizing $H$, we replace the two predicates $[x_i\le f(x_j)]$ and $[x_i\ge g(x_k)]$ with $[f(x_j)\ge g(x_k)]$, and replace $x_i$ with $f(x_j)$ in $H$ (i.e., reset $h_j(x_j)$ to $h_j(x_j)\sigma(f(x_j))$, which is still a step function with $O(n)$ complexity). Now, $i$ and $j$ are not free.

We stop a branch when there are no free indices left. At the end, we get a large but $O(1)$ number of subproblems, where in each subproblem, at least ${\left\lceil d/2\right\rceil}$ variables have been eliminated, i.e., the dimension is decreased to $d'\le{\left\lfloor d/2\right\rfloor}$. We solve each subproblem by Lemma \[lem1:anchored\] in ${\widetilde{O}}(n^{d'/2})$ time.

We now combine Theorem \[thm0:anchored\] and Lemma \[lem:bsp\] to solve Problem \[prob:anchored\]:

\[thm:anchored\] Problem \[prob:anchored\] can be solved in ${\widetilde{O}}(n^{d/3+{\left\lfloor d/2\right\rfloor}/6})$ time for any constant $d\ge 4$.

Apply Lemma \[lem:bsp\] to the $O(n)$ $(d-3)$-flats and $(d-2)$-flats through the $(d-3)$-faces and $(d-2)$-faces of the given orthants. This yields a partition of $B_0$ into cells.

Consider a cell ${\Delta}$. The number of $(d-3)$-flats intersecting ${\Delta}$ is $O(n/r^3)$, which can be made 0 by setting $r:=\Theta(n^{1/3})$. The number of $(d-2)$-flats intersecting ${\Delta}$ is $O(n/r^2)=O(n^{1/3})$. So, inside the cell ${\Delta}$, all orthants are 2-sided or 1-sided, with $O(n^{1/3})$ 2-sided orthants. The union of 1-sided orthants simplifies to the complement of a box (we can use orthogonal range searching or intersection data structures @AgaEriSURV [@BerBOOK] to identify the 1-sided orthants intersecting ${\Delta}$ and compute this box). We can thus apply Theorem \[thm0:anchored\] to maximize $H$ over the cell ${\Delta}$ in ${\widetilde{O}}((n^{1/3})^{{\left\lfloor d/2\right\rfloor}/2})$ time. As there are $O(r^d)=O(n^{d/3})$ cells, the total running time is ${\widetilde{O}}(n^{d/3}\cdot (n^{1/3})^{{\left\lfloor d/2\right\rfloor}/2})$.

Given $n$ points in ${\mathbb{R}}^d$ and a box $B_0$, we can compute the maximum-volume empty anchored box inside $B_0$ in ${\widetilde{O}}(n^{d/3+{\left\lfloor d/2\right\rfloor}/6})\le {\widetilde{O}}(n^{5d/12})$ time for any constant $d\ge 4$.

<span>Largest Empty Box in Higher Dimensions</span> {#sec:box}
===================================================

We now adapt the approach from Section \[sec:anchored\] to solve the original largest empty box problem in higher constant dimensions. By $d$ levels of divide-and-conquer, it suffices to solve the *point-restricted* version of the problem: given a set $P$ of $n$ points in ${\mathbb{R}}^d$, a fixed box $B_0$, and a fixed point $o$, find the largest-volume box $B\subset B_0$ that contains $o$ and is empty of points of $P$. An $O(T(n))$-time algorithm for the point-restricted problem immediately yields an $O(T(n)\log^dn)$-time algorithm for the original problem (in fact, the polylogarithmic factor disappears if $T(n)/n^{1+\delta}$ is increasing for some constant $\delta>0$). Without loss of generality, assume that $o$ is the origin.

By mapping a box $B=(-x_1,x_1')\times\cdots\times (-x_d,x_d')$ (which has volume $(x_1+x_1')\cdots (x_d+x_d')$) to the point $(x_1,x_1',\ldots,x_d,x_d')$ in $2d$ dimensions, and mapping each input point $p=(p_1,\ldots,p_d)$ to the orthant $(-p_1,\infty)\times (p_1,\infty)\times\cdots
(-p_d,\infty)\times (p_d,\infty)$ in $2d$ dimensions (and changing $B_0$ appropriately), the problem reduces to the following variant of Problem \[prob:anchored\], after doubling the dimension:

\[prob:box\] Define the function ${H_{\mbox{\scriptsize\rm new-vol}}}(x_1,\ldots,x_d)=(x_1+x_2)(x_3+x_4)\cdots (x_{d-1}+x_d)$ for an even $d$. Given a set $S$ of $n$ orthants in ${\mathbb{R}}^d$ and a box $B_0$, find the maximum of ${H_{\mbox{\scriptsize\rm new-vol}}}$ over $B_0 - \bigcup S$.

The above objective function ${H_{\mbox{\scriptsize\rm new-vol}}}$ is a bit more complicated than the one from Section \[sec:anchored\], and so further ideas are needed…

Preliminaries
-------------

For a multigraph $G$ with vertex set $\{1,\ldots,d\}$ (without self-loops), define a *$G$-function* $H:{\mathbb{R}}^d\rightarrow{\mathbb{R}}$ to be a function of the form $$H(x_1,\ldots, x_d)\ =\  \prod_{i=1}^d h_i(x_i)\cdot \prod_{e=ij\in G} (h'_e(x_i) + h''_e(x_j)),$$ where $h_i$, $h'_e$, and $h''_e$ are univariate step functions. The *complexity* of $H$ refers to the total complexity of these step functions.

A *pseudo-forest* is a graph where each component is either a tree, or a tree plus an edge—in the latter case, the component is called a *1-tree* (and we allow the extra edge to be a duplicate of an edge in the tree).

\[lem0\] Let $H$ be a $G$-function $H$ with $O(n)$ complexity. Given a box $B_0$, we can compute the maximum of $H$ over $B_0$ in ${\widetilde{O}}(n)$ time if $G$ is a forest, or ${\widetilde{O}}(n^2)$ time if $G$ is a pseudo-forest, for any constant $d$.

For the forest case: Pick a leaf $i$. Then $H$ is of the form $h(x_i)\cdot (h'(x_i)+h''(x_j))\ \cdots$, where $h,h',h''$ are step functions and $x_i$ does not appear in "$\cdots$". Define $F(\xi) := \max_{x\in{\mathbb{R}}} h(x)\cdot (h'(x)+\xi)$. Then $F$ is the upper envelope of $O(n)$ linear functions in the single variable $\xi$, and can be constructed in ${\widetilde{O}}(n)$ time by the dual of a planar convex hull algorithm @BerBOOK. We can eliminate the variable $x_i$ by replacing the $h(x_i)\cdot (h'(x_i)+h''(x_j))$ factor with $F(h''(x_j))$ (which is a step function in $x_j$ with $O(n)$ complexity). As a result, $H$ becomes a $(G-\{i\})$-function in $d-1$ variables. After $d$ iterations, the problem becomes trivial.

For the pseudo-forest case: We may assume the graph is connected, since we can maximize the parts of $H$ corresponding to different components separately. Pick a vertex $i$ that belongs to the unique cycle of $G$ (if exists). Then $G-\{i\}$ is a forest. By trying out all $O(n)$ different settings of $x_i$ (breakpoints of the step functions), the problem reduces to $O(n)$ instances of the forest case.

\[lem1\] Let $H$ be a $G$-function with $O(n)$ complexity, where $G$ is a pseudo-forest. Given a set $S$ of $n$ boxes in ${\mathbb{R}}^d$ and a box $B_0$, we can compute the maximum of $H$ over $B_0-\bigcup S$ in ${\widetilde{O}}(n^{d/2+1})$ time for any constant $d$.

Apply Lemma \[lem:bsp\] to the $O(n)$ $(d-2)$-flats through the boundaries of the orthants, together with the $O(n)$ $(d-1)$-flats $x_j=a$ for all breakpoints $a$ of the step functions appearing in $H$. This yields a partition of $B_0$ into cells.

Consider a cell ${\Delta}$. The number of $(d-2)$-flats intersecting ${\Delta}$ is $O(n/r^2)$, which can be made 0 by setting $r:=\Theta(\sqrt{n})$. So, inside the cell ${\Delta}$, we see only 1-sided orthants, and their union simplifies to the complement of a box. In addition, the number of $(d-1)$-flats intersecting ${\Delta}$ is $O(n/r)=O(\sqrt{n})$; in other words, the breakpoints of the step functions in $H$ relevant to the cell ${\Delta}$ is $O(\sqrt{n})$. We can thus apply Lemma \[lem0\] to maximize $H$ over the cell ${\Delta}$ in ${\widetilde{O}}((\sqrt{n})^2)$ time. As the number of cells is $O(r^d)=O(n^{d/2})$, the total running time is ${\widetilde{O}}(n^{d/2}\cdot (\sqrt{n})^2)$.

Algorithm
---------

We now modify the proof of Theorem \[thm0:anchored\] to solve Problem \[prob:box\] for the 2-sided orthant case:

![After removing vertex $i$ and adding edge $j\ell$, the graph $G$ remains a pseudo-forest.<span data-label="fig:graph"></span>](fig_graph.pdf)

\[thm0:box\] In the case when all input orthants are 2-sided, Problem \[prob:box\] can be solved in ${\widetilde{O}}(n^{d/4+1})$ time for any constant even $d$.

We maintain a $G$-function $H$. Initially, $H(x_1,\ldots,x_d)=(\sigma(x_1)+\sigma(x_2))(\sigma(x_3)+\sigma(x_4))\cdots(\sigma(x_{d-1})+\sigma(x_d))$, with $G$ being a matching with $d/2$ edges, where $\sigma(x)$ denotes the successor of $x$ among all $O(n)$ input coordinate values. We call an index $i$ *free* if $x_i$ appears exactly once in $H$ and is "unaltered" (i.e., $H$ is of the form $(\sigma(x_i) + h(x_\ell)) \cdots$ where $x_i$ does not appear in "$\cdots$"). All indices are initially free. We maintain the following invariants: at any time, (i) $G$ is a pseudo-forest with at most $d/2$ edges, and (ii) for each component $T$ of $G$ which is a tree (not a 1-tree), $T$ has at least two free leaves.

In each iteration, we pick a free leaf $i$ in some component $T$ of $G$ which is a tree. As before, we rewrite the expression $E$ as a disjunction of $O(1)$ subexpressions, where in each subexpression, only two occurrences of $x_i$ remain—in a predicate of the form $[x_i\le f(x_j)]$, and another predicate of the form $[x_i\ge g(x_k)]$.

We branch off to maximize $H$ for each of these subexpressions separately. In such a subexpression, to eliminate the variable $x_i$ while maximizing $H$, we replace the two predicates $[x_i\le f(x_j)]$ and $[x_i\ge g(x_k)]$ with $[f(x_j)\ge g(x_k)]$, and replace $x_i$ with $f(x_j)$ in $H$ (since $x_i$ is free). Now, $i$ and $j$ are not free. Also, in the graph $G$, the unique edge $i\ell$ incident to $i$ is replaced by $j\ell$ (unless $j=\ell$). If $j$ is in the same component $T$ as $i$, then $T$ becomes a 1-tree; otherwise, two components are merged and the new component is either a tree with at least two free leaves, or a 1-tree. (See Figure \[fig:graph\].) So, the invariants are maintained.

We stop a branch when there are no free indices left. At the end, we get $O(1)$ subproblems, where in each subproblem, all components are 1-trees, and so the number of nodes is exactly equal to the number of edges, implying that the dimension is $d'\le d/2$. Now we can apply Lemma \[lem1\] to solve these subproblems in ${\widetilde{O}}(n^{d'/2+1})$ time.

Problem \[prob:box\] can be solved in ${\widetilde{O}}(n^{(5d+4)/12})$ time for any constant even $d$.

Following the proof of Corollary \[thm:anchored\] but using Theorem \[thm0:box\] instead of Theorem \[thm0:anchored\] gives running time ${\widetilde{O}}(n^{d/3} \cdot (n^{1/3})^{d/4+1})$.

Applying the above corollary in $2d$ dimensions, we finally obtain:

Given $n$ points in ${\mathbb{R}}^d$ and a box $B_0$, we can compute the maximum-volume empty box inside $B_0$ in ${\widetilde{O}}(n^{(5d+2)/6})$ time for any constant $d$.

Remarks {#sec:rmks}
=======

#### On the 2D algorithm.

The $2^{O(\log^*n)}$ factor can be analyzed more precisely (an upper bound of $3^{\log^*n}$ can be shown with minor changes to the algorithm). A question remains whether the extra factor could be further lowered to inverse-Ackermann, or eliminated completely.

The previous algorithm by Aggarwal and Suri @AggSur used matrix searching techniques, namely, for finding row minima in certain types of partial Monge matrices. We are able to bypass such subroutines because we have focused our effort on solving the *decision problem* (due to the author's randomized optimization technique @ChaSoCG98). Generally, the row minima problem is equivalent to the computation of lower envelopes of pseudo-rays and pseudo-segments, not necessarily of constant complexity @ChaSODA21. However, to solve the decision problem, we only need lower envelopes of pseudo-rays and pseudo-segments of constant complexity (formed by hyperbolas), for which there are simpler direct methods, as we have noted in Lemma \[lem:LE\]. (Incidentally, the proof we gave for reducing Lemma \[lem:LE\](b) to (a) is essentially equivalent to Aggarwal and Klawe's reduction of row minima in double-staircase to staircase matrices @AggKla; a similar idea has also been used in dynamic data structures with "FIFO updates" @ChHePr.)

On the other hand, it should be possible to modify our approach to get improved *deterministic* algorithms for 2D largest empty rectangle, by solving the optimization problem directly and using known matrix searching subroutines @KlaKle, though details are more involved and the running time seems slightly worse than in our randomized algorithm.

It is theoretically possible to devise an optimal algorithm for Problem \[prob1\] without knowing the true complexity of the algorithm, since by a constant number of rounds of recursion in our method, the problem is reduced to subproblems of very small size (say, $\log\log\log\log n$), for which we can afford to explicitly build an optimal decision tree (this type of trick appeared before in the literature @Lar [@PetRam]).

#### On the higher-dimensional algorithms.

Our approach in higher dimensions works for maximizing the perimeter (sum of edge lengths) of the box as well. In fact, the algorithm for the simpler, largest empty *anchored* box problem should suffice here after doubling the dimension, since the required objective function here is $H_{\mbox{\scriptsize\rm perim}}(x_1,\ldots,x_d)=x_1+\cdots+x_d$, which is "similar" to ${H_{\mbox{\scriptsize\rm vol}}}(x_1,\ldots,x_d)=x_1\cdots x_d$.

For the largest empty anchored box problem, the ${\widetilde{O}}(n^{5d/12})$ time bound can be further improved to ${\widetilde{O}}(n^{(7d+6)/18})$, by building on the graph-theoretic ideas from Section \[sec:box\], as we show in <span>Appendix \[sec:anchored:new\]</span>. Still further improvements of the exponent is likely possible, by working with $G$-functions for *hypergraphs* $G$, not just graphs, though improvement on the fraction $7/18$ appears very tiny and requires $d$ to be a very large constant, and the algorithm becomes more complicated. For the largest empty box problem, we currently don't know how to improve the fraction $5/6$, even using hypergraphs. It remains a fascinating question what the best fraction $\beta$ is for which the problem could be solved in $O(n^{\beta d +o(d)})$ time.

On the conditional lower bound side, another relevant question is whether Problem \[prob:anchored\] or \[prob:box\] remain $W[1]$-hard with respect to the parameter $d$ in the special case of 2-sided orthants.

#### Acknowledgement.

I thank David Zheng for discussions on the 2D problem.

Largest Empty Anchored Box in Higher Dimensions<span>\
</span> (Further Improved) {#sec:anchored:new}
======================================================

In this section, we return to the largest empty *anchored* box problem and describe a further improvement to the result in Section \[sec:anchored\], by incorporating the graph-theoretic approach from Section \[sec:box\].

For a multigraph $G$ with vertex set $\{1,\ldots,d\}$ (without self-loops), define a *generalized $G$-function* $H:{\mathbb{R}}^d\rightarrow{\mathbb{R}}$ to be a function of the form $$H(x_1,\ldots, x_d)\ =\  \prod_{i=1}^d h_i(x_i)\cdot \prod_{e=ij\in G} h'_e(x_i,x_j),$$ where each $h_i$ is a univariate step function and each $h'_e$ is a bivariate step function. Here, in a bivariate step function $h'_e$, the domain is divided into grid cells by horizontal and vertical lines, and $h'_e$ is constant in each grid cell; the complexity of $h'_e$ refers to the number of horizontal and vertical lines. The *complexity* of $H$ is the total complexity of the univariate and bivariate step functions.

\[lem0:new\] Let $H$ be a generalized $G$-function with $O(n)$ complexity, where $G$ is a matching. Given a box $B_0$, we can compute the maximum of $H$ over $B_0$ in $O(n^2)$ time for any constant $d$.

Trivial.

\[lem1:new\] Let $H$ be a generalized $G$-function with $O(n)$ complexity, where $G$ is a matching. Given a set $S$ of $n$ boxes in ${\mathbb{R}}^d$ and a box $B_0$, we can compute the maximum of $H$ in $B_0-\bigcup S$ in $O(n^{d/2+1})$ time for any constant $d$.

Similar to the proof of Lemma \[lem1\], but using Lemma \[lem0:new\] instead of Lemma \[lem0\] as subroutine.

We now improve Lemma \[lem1:anchored\] for 2-sided orthants:

\[lem1:anchored:new\] Let $H$ be a simple function with $O(n)$ complexity. Given a set $S$ of $n$ 2-sided orthants in ${\mathbb{R}}^d$ and a box $B_0$, we can compute the maximum of $H$ in $B_0-\bigcup S$ in ${\widetilde{O}}(n^{d/3+1})$ time for any constant $d$.

We maintain a generalized $G$-function $H$. Initially, $G$ consists of $d$ isolated vertices. We repeatedly find variables $x_i$ to eliminate:

-   <span>Case 1:</span> there is an isolated index $i$ in $G$. As before, we rewrite the expression $E$ as a disjunction of $O(1)$ subexpressions, where in each subexpression, only two occurrences of $x_i$ remain—in a predicate of the form $[x_i\le f(x_j)]$, and another predicate of the form $[x_i\ge g(x_k)]$.

    We branch off to maximize $H$ for each of these subexpressions separately. In such a subexpression, to eliminate the variable $x_i$ while maximizing $H$, we replace the two predicates $[x_i\le f(x_j)]$ and $[x_i\ge g(x_k)]$ with $[f(x_j)\ge g(x_k)]$, and replace $h_i(x_i)$ with $h'(x_j,x_k) := \min_{x: g(x_k)\le x\le f(x_j)} h_i(x)$ in $H$. We remove $i$ from $G$, and add edge $jk$ to $G$.

-   <span>Case 2:</span> there is an index $i$ of degree at least 2 in $G$. We try out all $O(n)$ different settings of $x_i$ (breakpoints of the step functions), and obtain $O(n)$ instances in which $i$ is removed from $G$.

We stop a branch when neither case is applicable, i.e., all indices in $G$ have degree 1, i.e., $G$ is a matching. Here, we can apply Lemma \[lem1:new\] to solve the problem.

Consider one branch. Suppose Case 1 is applied $s$ times and Case 2 is applied $t$ times. At the end, the number of vertices in $G$ is $d':=d-s-t$, and the number of edges in $G$ is at most $s-2t$ (since Case 1 adds one edge and Case 2 removes at least two edges). Since $G$ is a matching at the end, the number of vertices is twice the number of edges. Thus, $d-s-t\le 2(s-2t)$, i.e., $s\ge d/3+t$, i.e., $d'\le 2d/3-2t$. Since $O(n^t)$ instances are generated and Lemma \[lem1:new\] has cost $O(n^{d'/2+1})$, the total cost is ${\widetilde{O}}(n^t\cdot n^{d'/2+1})
\le {\widetilde{O}}(n^{d/3+1})$.

The above lemma improves the time bound in Theorem \[thm0:anchored\] to $O(n^{{\left\lfloor d/2\right\rfloor}/3+1})$. This in turn improves the time bound in Corollary \[thm:anchored\] to $O(n^{d/3}\cdot (n^{1/3})^{{\left\lfloor d/2\right\rfloor}/3+1}) 
= O(n^{(d+1)/3 + {\left\lfloor d/2\right\rfloor}/9})$.

Given $n$ points in ${\mathbb{R}}^d$ and a box $B_0$, we can compute the maximum-volume empty anchored box inside $B_0$ in ${\widetilde{O}}(n^{(d+1)/3 + {\left\lfloor d/2\right\rfloor}/9})\le {\widetilde{O}}(n^{(7d+6)/18})$ time for any constant $d\ge 3$.

[^1]: Department of Computer Science, University of Illinois at Urbana-Champaign (hbaxter@example.net). This research has been supported in part by NSF Grant CCF-1814026.

[^2]: Aggarwal and Suri's first algorithm can be sped up to run in near $O(n\log^2n)$ time as well, since it relied on a subroutine for finding row minima in Monge staircase matrices, a problem for which improved results were later found @KlaKle [@ChaSODA21]; but these results do not appear to lower the cost of Aggarwal and Suri's second algorithm.

[^3]: Throughout the paper, ${\widetilde{O}}$ notation hides polylogarithmic factor.

[^4]: The solution is simple: for each $p\in P$, we find the lowest point $q_p\in Q$ with $x$-coordinate in the interval $[x^-_{s(p)},x^+_{s(p)}]$, and take the maximum of $(x^+_{s(p)}-x^-_{s(p)})(y_{t(q_p)} - y_{s(p)})$. All these lowest points $q_p$ can be found "bottom-up" in the tree formed by the intervals $\{[x^-_{s(p)},x^+_{s(p)}]: p\in P\}$, in linear total time.

[^5]: A weaker time bound was stated in @ChaFOCS13 [Lemma 4.6], but the output-sensitive time bound follows directly from the same construction.

{'source': 'arXiv_out/2103'}