arXiv:2608.25197cs.DSAug 2026

Manuscript Offprint

arXiv:2608.25197

Exact algorithms for optimal discretization

László Kozma, Junqi Tan

Abstract

The optimal discretization problem asks, given two disjoint sets of points RR and BB in the plane, for a minimal family of horizontal and vertical lines that separate the two sets, so that no cell delimited by the lines contains points from both sets. The problem arises as a pre-processing in supervised machine learning, and has received significant attention in parameterized algorithms. Answering the question raised by Bonnet, Giannopoulos, and Lampis [IPEC 2017] and Froese [PhD thesis, 2018], it was shown by Kratsch, Masařík, Muzi, Pilipczuk, and Sorge [SODA 2021] that optimal discretization admits a fixed-parameter algorithm with running time 2O(k2log⁡k)⋅nO(1)2^{\mathcal{O}(k^2 \log k)} \cdot n^{\mathcal{O}(1)}, where kk is the solution size and n=∣R∣+∣B∣n = |R| + |B|.

In this paper we give an algorithm for optimal discretization that runs in time O(1.9602n)\mathcal{O}(1.9602^n). We also study the related point separation problem that asks to separate all input points by axis-parallel lines. For this problem we obtain an algorithm with runtime O(1.8906n)\mathcal{O}(1.8906^n). Our guarantees follow from structural observations about bichromatic and monochromatic point sets, and hold even if points are allowed to share coordinates. To our knowledge, these are the first improvements over the trivial 2n2^n bound for both problems.

1 Introduction

We study two natural geometric separation problems for planar point sets. In the first problem, given two disjoint sets of points R and B in the plane, the task is to find a set of at most k axis-parallel lines avoiding the input points, so that every cell induced by these lines is either empty or contains points from only one of the two sets.

The problem is known as optimal discretization and its original motivation comes from pre-processing in machine learning tasks. Given a set of data points with continuous numerical features and class labels, we would like to round the features to discrete values using a set of well-chosen thresholds, such as to guarantee that no two points with different class labels are mapped to the same point. Here the horizontal and vertical lines represent the thresholds for two features and the grid induced by these lines gives a discretized view of the data. (For a broader overview of the history of the problem in the context of machine learning, we refer to [7, §5], [10], and references therein.)

Optimal discretization has been well studied both in exact and approximate settings. The problem was shown to be APX-hard by Călinescu, Dumitrescu, Karloff, and Wan [2]; see also [13, 3] for earlier NP-hardness proofs. Bonnet, Giannopoulos, and Lampis [5] showed that the problem is FPT when parameterized by the size of the smaller set t=min⁡{∣R∣,∣B∣}t = \min\{|R|, |B|\} and gave an O∗(9t)\mathcal{O}^*(9^t)-time algorithm using a reduction to many instances of 2-SAT. They also conjectured that the problem is FPT when parameterized by the solution size kk, a question also raised by Froese [7, §5.5], as a special case of co-clustering. The FPT status of the problem was confirmed by Kratsch, Masařík, Muzi, Pilipczuk, and Sorge [10]. Their approach starts with a coarse solution obtained from an approximation, which is gradually transformed into an exact solution, by formulating the refinement as a structured CSP problem; the final running time is of the form 2O(k2log⁡k)⋅nO(1)2^{\mathcal{O}(k^2 \log k)} \cdot n^{\mathcal{O}(1)}.

Exact algorithms for optimal discretization

The problem admits an almost trivial algorithm with running time O∗(2n)\mathcal{O}^{*}(2^n) or O∗(nk)\mathcal{O}^{*}(n^k), as follows. Let HH and VV be the horizontal and vertical lines of the solution. Guessing either HH or VV, the other set of lines can be placed optimally using a simple greedy strategy. Since there are at most n−1n - 1 essentially different locations for horizontal and for vertical lines (between coordinates of the input points) the “guessing” amounts to trying up to (nk)≤min⁡{nk,2n}\binom{n}{k} \leq \min\{n^k, 2^n\} subsets of locations, while the second phase requires only polynomial time. The running time can be improved to O∗(nk/2)\mathcal{O}^{*}(n^{k/2}), if we guess the smaller of the two sets HH and VV, of size at most k/2k/2. This however, would improve the 2n2^n bound only by a polynomial factor. (Note that if kk is unknown, it can be found, e.g., by binary search.)

For moderately large values of the solution size, e.g., k∈Ω(log⁡n)k \in \Omega(\log n), the FPT algorithm mentioned above is slower than the naive exponential algorithms, and as pointed out by Kratsch et al. [10], improving the dependence on kk in the FPT result appears to be difficult. This motivates designing algorithms with better dependence on nn in the exponential regime.

In this paper we show the following main result.

▶ Theorem 1. The optimal discretization problem can be solved in time O(1.9602n)\mathcal{O}(1.9602^{n}).

A natural variant of the problem is to have a single input point set P, asking for a set of at most k axis-parallel lines avoiding the points, so that every cell induced by the lines contains at most one input point. This problem can be seen either as a natural geometric separation task in itself, or as a multiclass version of the above discretization problem where each point has a distinct class label. We refer to this problem simply as point separation.

Similarly to optimal discretization, point separation is known to be NP-hard and APX-hard, and both problems admit a polynomial time 2-approximation [2]. For point separation an FPT-algorithm easily follows from the observation that to create at least n cells, the solution size must be at least n\sqrt{n}. Exponential-time enumeration can be applied, similarly to optimal discretization, yielding a running time of (nk)≤(k2k)∈2O(klog⁡k)\binom{n}{k} \leq \binom{k^2}{k} \in 2^{\mathcal{O}(k \log k)} (omitting polynomial factors).

Our second result gives an improved exponential running time for point separation.

▶ Theorem 2. The point separation problem can be solved in time O(1.8899n)\mathcal{O}(1.8899^n) if the points are in general position, and in time O(1.8906n)\mathcal{O}(1.8906^n) otherwise.

To our knowledge, these are the first algorithms with runtime below the 2n2^n-barrier for both problems. Several natural problems admit algorithms with runtime of the form 2n2^n, typically based on subset enumeration, and designing algorithms with runtimes cnc^n with c<2c < 2 has been a central theme in the field of exponential algorithms [6]. Landmark results of this kind include algorithms for maximum independent set [17], subset sum [9], Hamiltonian cycle [1], max cut [18], and 3-CNF SAT [16]. (For each of the mentioned problems, nn is the standard problem-specific input parameter.) Prominent problems that have resisted such improvements include graph coloring, CNF SAT, set cover, and TSP.

The search for algorithms that break a “triviality barrier” of 2n2^{n} has often resulted both in problem-specific structural insight, and in general techniques that have seen further applications; these include branch and reduce, measure and conquer, split and list, as well as powerful algebraic techniques; see [6, 15] for surveys.

Further related work. The optimal discretization problem we study in this paper has also been studied before under the names axis-parallel red-blue separation [5], minimum linear classification [12], or supervised discretization [19], and further variants of both problems have also been considered, e.g., see [14, 11, 8, 13].

Both problems can be seen as special cases of rectangle stabbing, a problem that has been widely studied in computational geometry; in contrast to optimal discretization and point separation, this more general version is W[1]W[1]-hard [4]. Another generalization of optimal discretization, where lines of arbitrary slopes are allowed, has also been shown to be W[1]W[1]-hard [5].

A higher dimensional variant of point separation has also been defined, and Călinescu et al. [2] show that in dd dimensions the problem admits a dd-approximation.

Overview of our approach. Our algorithmic idea is very simple, and is based on the naive search algorithm described earlier. We show that, for optimal discretization, assuming the nn input points to be in general position with no pair of points sharing xx- or yy-coordinates, the optimal solution can be transformed such as to contain at most 0.4n0.4n lines of one orientation, i.e., min⁡{∣H∣,∣V∣}≤0.4n\min\{|H|, |V|\} \leq 0.4n. For point separation we show the stronger bound min⁡{∣H∣,∣V∣}≤n/3\min\{|H|, |V|\} \leq n/3. These results allow reducing the search space, yielding the stated running times. We show the bound to be optimal for point separation; for optimal discretization it is not far from optimal in the following sense: there is a two-color point set of arbitrarily large size in which every optimal solution must have at least 0.3n0.3n lines of both orientations. Closing the gap between these upper and lower bounds is an intriguing question we leave open.

Our running time bounds also apply if we relax the generality requirement, i.e., allowing input points to align horizontally or vertically. In this case the solutions can no longer be assumed to be skewed in the above sense; for both problems there are simple examples requiring ∣H∣=∣V∣=(n−1)/2|H| = |V| = (n - 1)/2 lines in the solution. Yet, if many lines are “forced” by pairs of points that are aligned horizontally or vertically, then the solution can be shown to have a simpler form, again, reducing the search space to yield the bounds of Theorem 1 and Theorem 2.