Optimal Clustering in Stable Instances Using Combinations of Exact and Noisy Ordinal Queries

: This work studies clustering algorithms which operates with ordinal or comparison-based queries (operations), a situation that arises in many active-learning applications where “dissimilarities” between data points are evaluated by humans. Typically, exact answers are costly (or difﬁcult to obtain in large amounts) while possibly erroneous answers have low cost . Motivated by these considerations, we study algorithms with non-trivial trade-offs between the number of exact (high-cost) operations and noisy (low-cost) operations with provable performance guarantees. Speciﬁcally, we study a class of polynomial-time graph-based clustering algorithms (termed Single-Linkage) which are widely used in practice and that guarantee exact solutions for stable instances in several clustering problems (these problems are NP-hard in the worst case). We provide several variants of these algorithms using ordinal operations and, in particular, non-trivial trade-offs between the number of high-cost and low-cost operations that are used. Our algorithms still guarantee exact solutions for stable instances of k-medoids clustering, and they use a rather small number of high-cost operations, without increasing the low-cost operations too much.


Introduction
Clustering is a fundamental and widely studied problem in machine learning and in computational complexity as well. Intuitively, the goal is to partition a given set of points X (data set) into k clusters, each cluster corresponding to a group of "similar" data according to some underlying distance function d(·). Though most of the clustering problems are NPhard in the worst case, for real data, certain (relatively simple) heuristics seem to perform quite well. One theoretical justification to support this empirical observation is that "real" instances have some "nice" distribution, and some polynomial-time algorithms come with the guarantee that, on these inputs, they return optimal solutions. Along these lines, one successful concept is that of stability of the input, meaning that a "small" perturbation of the input does not change the optimal solution (though it may change its value).
Quite surprisingly, for a rather general class of clustering problems, the following very simple algorithm guarantees exact solutions in stable instances in polynomial-time [1][2][3] (see also [4] for a nice introduction). Roughly speaking, this algorithm first computes a (minimum) spanning tree over the data pairwise distances or dissimilarities, and then removes a suitable subset of edges to obtain the optimal k-clustering. The latter step amounts to identify the k − 1 edges whose removal partitions the spanning tree into k clusters (the nodes of the resulting forest) in order to minimize the underlying cost function of the clustering problem (the exact cost function depends on how we define the "center" of the clusters and on the distances of the points in the cluster to its center).
The implicit assumption is that the algorithm is provided with the correct pairwise dissimilarity/distances metric between all pairs of data points. In this work, we take a step further and consider the natural setting where we can only compare distances and these comparisons are also noisy. Furthermore, by accessing some type of expensive (expert) oracle, we can make sure that certain comparisons are correctly reported, though these operations are inherently more expensive and thus we would like to use as few as possible. In a nutshell, our work considers and combines the following three aspects that are often present in practical machine learning approaches: • Using only ordinal information; • Dealing with noisy data; • Allowing expensive operations to remove errors.
This situation arises, for example, in semi-active learning approaches where the pairwise dissimilarity between objects (data points) is evaluated by humans via simple comparison queries (see, e.g., [5][6][7] and references therein). These are inherently subject to erroneous evaluations. Moreover, very often, the task is to compare objects and their pairwise dissimilarities. Such queries can also be of varying difficulty and thus more or less informative/costly. It is therefore natural to ask the following questions: Which guarantees are still possible under such model?
What trade-offs between expensive and non-expensive (noisy) operations still allow for finding optimal solutions?

Our Contribution
In this work, we address these questions by (i) introducing a formal model and (ii) by considering a class of clustering problems/algorithms in this model. Specifically, we consider k-medoids clustering which applies to general dissimilarities of data (unlike, e.g., k-means), and for which the above "minimum-spanning-tree-based" optimal algorithm for stable instances can be implemented using (certain) ordinal queries. We detail our contributions and its relation to prior work in the following sections.

Our Model
This paper introduces a natural setting where we can only compare distances, and these comparisons are generally noisy; though use some sort of expensive (expert) oracle, we can make sure that certain comparisons are correctly reported. Our model (see Section 2 for formal definitions) captures the following aspects: 1.
Using only ordinal information. Distances or dissimilarities can only be compared and not directly evaluated. One example of such queries is [5][6][7] Which one between y and y is more dissimilar to x?
Concretely, this means that we can compare d(x, y) with d(x, y ) for some dissimilarity function d(·). In our model, we allow for comparing arbitrary groups (sum) of pairwise distances.

2.
Dealing with noisy results. Comparisons are in general noisy and the resulting error is persistent. Due to measurements, we may report the wrong answer with probability bounded by some error probability p < 1/2, and repeating the same measurements would lead to the same answer [7][8][9]. (In order to import some results from the literature, we shall typically assume p < 1/16. All our results automatically extend to larger p if these prior results in the literature also do.) 3.
Allowing expensive operations to remove errors. Errors can be fixed by performing some kind of expensive comparison. In this case, we know the answer is correct, but we would like to limit the total number of such expensive operations (see e.g., [10] for a survey on various practical methods).
This setting falls into the dual-mode framework in [11], where several optimization problems can be optimally solved using either only low-cost operations or a suitable combination with few high-cost ones. This framework suggests to evaluate the complexity of an algorithm by explicitly counting the low-cost and high-cost operations separately. Without errors, or ignoring that exact operations have high-cost, the problem falls into the class of problems that can be solved only with ordinal operations. Without the aid of high-cost operations that is using only noisy comparisons, the problem has been recently studied in the context of active learning under various query and error models (see, e.g., [12,13] and below for further discussions).

Algorithms and Bounds for k-Medoids
We provide new polynomial-time algorithms for k-medoids clustering. These algorithms achieve the following trade-offs between the number of high-cost and low-cost operations to compute optimal k-clustering in stable instances (with stability parameter γ ≥ 2-see Definition 1): • In Section 3, we investigate variants of the popular Single-Linkage algorithm, and its enhanced version Single-Linkage++ analyzed in [1][2][3]. (Following [4], we call Single-Linkage the simpler algorithm, which often used in practice, and Single-Linkage++ the enhanced version with provable guarantees [1][2][3]). This algorithm consists of two distinct phases (computing a minimum spanning tree and removing a suitable set of edges to obtain a clustering). A naive implementation, using only high-cost comparisons, would require O(n 2 ) for such operations for the first phase and O(n log n) for the second one. The trade-offs are summarized in Table 1, where we also consider a naive (simpler) version of the algorithm with no approximation guarantee (this serves to illustrate some key ideas and develop some necessary tools). All other variants are either exact or guarantee a 2-approximation in the worst case. At this point, some comments are in order:

-
The overall algorithm consists of a combination of Phase 1 and Phase 2, and thus the overall complexity is given by the sum of these two. The total number of operations (also accounting for internal computations) is comparable with the sum of the high-cost and low-cost operations. -Phase 1 improves over the naive implementation (Remark 3) under some additional assumptions on the data (in particular, larger stability parameter γ > 2 helps, as well as a small radius-the ratio d min between the largest and the smallest distance between two points).

-
The naive algorithm (Single-Linkage) assumes that Phase 1 has been already solved and implements a simpler Phase 2 (the complexity bounds refer only to the latter). This algorithm is in fact a widely used heuristic with additional theoretical guarantees for hierarchical clustering (see, e.g., [14,15]). -Phase 2 can be implemented using very few high-cost operations, if we content with a 2-approximate solution. Exact solutions use larger number high-cost operations. Though the dynamic programming (DP) approach has a better theoretical performance for large k, the other algorithm is much simpler to implement (for example, it does not require memory O(k 2 n 4 log n) used to store the DP table).
We remark that the best combination between Phase 1 and Phase 2 depends on k and, in some cases, on additional properties of the input data X.

•
In Section 4, we show that, under additional assumptions on the input data, and a slightly more powerful comparison model, it is possible to implement exact or approximate same-cluster queries (see Section 4.1 and Lemma 10 therein). • Since same-cluster queries may require some additional power, in Section 4.2, we provide algorithms which use few same-cluster queries in combination with our original (low-cost and high-cost) comparison operations. The obtained bounds are summarized in Theorem 5 and Theorem 6. Intuitively speaking, the ability to preform "few" exact same-cluster queries allows for us to reduce the number of high costoperations significantly, at least for certain instances: -When the optimal solutions has approximately balanced clusters, O(k log k) same-cluster queries are enough, and the additional high-cost comparisons are O(log 2 n). Both bounds scale with the cluster "unbalance" n/n 1 , where n 1 is the smallest cluster size (slightly better bounds for the number of same-cluster queries hold).

-
The additional assumption on the input data is only required to be able to implement these few same-cluster queries directly from our model. The result still applies in general if these same-cluster queries can be be implemented in a different-perhaps quite expensive-fashion.

-
The aforementioned condition to simulate same-cluster queries, essentially requires that, in the optimal solution, points in the same cluster have a distance of at most γ − 1 times the minimum distance. For larger γ, this condition becomes less stringent, though of course we require a larger stability coefficient. Table 1. Trade-off for various algorithms for γ-pertubation-stable instances (γ ≥ 2) in this work. We distinguish the two-phases of the Single-Linkage++ algorithm (and a simpler naive version) and show the corresponding number of high-cost and low-cost comparisons depending on the size n of the dataset X, the number k of clusters; Parameters d (X) min and d (X) max denote the minimum and the maximum distance between points in X, respectively.

High-Cost Low-Cost
Single-Linkage (Phase 2 naive) All above mentioned algorithms (and results) hold with high probability, that is, with probability at least 1 − n −c , for some constant c > 0 (we actually prove success probability at least 1 − 3 n or larger in all cases), where the probability is on the outcome of the distance comparisons (errors).

Techniques and Relation to Prior Work
This work focuses on the so-called k-medoids clustering problem, where the center of each cluster (its medoid) must be a point of the cluster (and thus of the data set) [16][17][18][19]. This is slightly different from k-means, where the centroid of a cluster may not be an element of the cluster/data set. It is well known that k-medoids clustering has several advantages. First, it can be applied to any dissimilarity/distance function between data points, while k-means requires the points to be embedded in some Eulidean space . Moreover, it is well known that k-medoids is more stable to outliers (see, e.g., [20]). Despite k-medoids being NP-hard, it has been recently shown that, for stable instances, a relatively simple (Single-Linkage++) algorithm solves the problem exactly in polynomial-time [1][2][3] (see also [4] for a nice introduction).
The algorithms implementing Single-Linkage++ (Table 1) are based on two algorithmic results regarding, respectively, approximate sorting with noisy comparisons [21], and approximate matroid maximization with high-cost and low-cost operations [11]. The dynamic implementation of Phase 2 is instead an adaptation of the algorithm in [3] to work with our comparison-based model. Their algorithmic result is in fact more general, and it applies to the class of center-based clustering problems (intuitively, the solution and its cost are uniquely determined by a set of centers-in our case medoid).
Without allowing high-cost operations that are using only noisy comparisons, the problem has been studied in the context of (semi-supervised) active learning which involves (noisy) comparison queries of varying "complexity". Specifically, Refs. [12,13] consider comparisons between pairs of classifiers in some fixed hypothesis class (a noisy comparison between two candidate classifiers h and h * consists of comparing the loss of these classifiers on a small set labelled data set). In [22], the authors consider queries of the form " f (x) ≥ f (y)" for specific functions f (·). Several works consider ordinal queries involving distances between (few) points: "triplets" are considered in [5,7] with queries of the form "d(x, y) ≥ d(x, z)" (is x more similar to y or to z) and in [23] with queries giving the outlier among the three points "d(x, y) ≤ min{d(x, z), d(y, z)}". In [14], "quadruples" queries of the form "d(x, y) ≥ d(z, w)" are used to simulate more complex queries (e.g., implementing the naive Single-Linkage algorithm in a noisy-free setting). In [8,9], queries involving some "scalar/multiplicative" factor α ≥ 1-similar to what we use to simulate same-cluster queries-are used; Their queries are of the form "αd(x, z) ≥ d(y, z)" and the answer is correct if the inequality holds, but the oracle may not answer whenever these distances are "close", i.e., d(x, z) ≤ d(y, z) < αd(x, z); [9] considers the variant in which the answer is adversarially wrong in this case.
It widely believed that same-cluster queries may be difficult to implement in practice, though very powerful. Algorithms based on same-cluster queries both exact and with errors have largely been studied. The error-free/exact case is closely related to our "all at high cost" implementations (assuming one same-cluster query costs as one exact call in our model). Specifically, Ref. [24] considers k-means and provide an algorithm using O(k 2 log k + k log n) same cluster queries, while Ref. [25] uses O( k 14 log k log n 6 ) same-cluster queries for computing (1 + )-approximate correlation clustering; Ref. [26] provides an exact algorithm using 2C OPT same-cluster queries, where C OPT denotes the number of "disagreements" in the optimal solution. Same-cluster queries can also solve non-centerbased clustering problems [27], where the corresponding algorithm uses O(k 3 log k log n), with the hidden constant depending exponentially in the dimensionality of the clusters. Regarding noisy same-cluster queries, Ref. [28] uses O( nk log n (1−2p) 2 ) same-cluster queries to reconstruct the "latent" clusters. The closest result to ours is probably [29], proving that γ-pertubation-stable instances with γ ≥ 3 can be solved using O(n log 2 n) noisy samecluster queries [29], and with O(n) queries in the noise-free case. Their result applies to a rather general class of center-based clustering problems (including ours). On the one hand, our algorithms use fewer low-cost noisy comparisons, namely O(n log n), though for a restricted class of inputs; for balanced clusters, the same-cluster queries are O(k log k), though we use exact queries. On the other hand, in some cases, same-cluster queries may be harder or more costly than comparisons of distances, and thus the costs may be incomparable in general. Finally, our algorithm using few same-cluster queries uses similar ideas to (coupon collector and the double Dixie cup extension) in [30] for k-mean instances that satisfy a γ-margin property (similar to γ-perturbation-stability, though not equivalent).

Model and Preliminary Definitions
An instance is a pair (X, d) where X is a dataset of n = |X| points whose pairwise distances are specified by a non-negative function d : X × X → R + satisfying symmetry and triangle inequality: d(x, x) = 0, d(x, y) = d(y, x), and d(x, y) ≤ d(x, z) + d(z, y) for any three points x, y, z ∈ X. The distance function extends naturally to subsets of pairwise distances e = (x, y), i.e., subsets of edges. Specifically, for E = X × X being the set of all edges, and for any S ⊆ E of pairwise distances, we let (1)

Stable Instances
For a given metric space (X, d) as above and a positive integer k, a clustering is a partition C = {C 1 , . . . , C k } of X. The cost of a cluster C i with respect to a point x ∈ X is defined as The medoid (or centroid) of each cluster C i is the point in that cluster minimizing this cost, i.e., c i := arg min x∈C i Cost(C i , x), and the cost of a cluster is simply Cost(C i ) := Cost(C i , c i ). Then, the cost of the clustering is the sum of the cost of each cluster, A clustering that minimizes this cost is called optimal k-clustering. (In the literature, this is sometimes called k-medoid. Since in this work we use centroid and medoid interchangeably, we simply use the term k-centroid.) Definition 1 (γ-perturbation stability). A γ-perturbation of a metric space (X, d), for γ ≥ 1, is another metric space (X, d ) such that, for all x, y ∈ X, For a given positive integer k, a metric space (X, d) is γ-perturbation-stable if there is a k-clustering C * 1 , . . . , C * k , which is the unique optimal k-clustering in every γ-perturbation of (X, d).

Remark 1.
Observe first that the above definition restricts the perturbations from being metric too. Moreover, if a metric space is γ-perturbation-stable, then it has a unique optimal solution (regardless of the value of γ ≥ 1).
For γ ≥ 2, there exists an exact polynomial-time algorithm for the k-clustering problem [3] (see also [2] for algorithms for γ ≥ 3). The algorithm exploits the following key property of such stable instances. Intuitively, in γ-perturbation-stable instances, in the optimal clustering, every point is "much closer" to the centroid of its own cluster than to any other centroid: Lemma 1 (γ-center proximity [2,3]). Let (X, d) be γ-perturbation-stable and let C * 1 , . . . , C * k be its (unique) optimal solution. Then, for every x ∈ X, with x ∈ C * i , and every j = i, we have that where c * i , c * j are the respective centroids of C * i , C * j .

Comparisons and Errors
We consider the scenario in which the distances d(x, y) between points, as well as those relative to subsets (1), are not directly measurable. Distances can only be compared either using a cheap but erroneous operation or an expensive but always correct operation. Specifically, we let O H (·) denote the expensive and reliable operation (oracle) defined as for any two subsets E 1 , E 2 ⊆ E. The cheap but erroneous operations (oracle) is denoted by O L (·), and its answers are wrong with a probability of at most p independently across all pairs E 1 and E 2 . That is, for any two subsets E 1 , E 2 ⊆ E as above, and these errors are persistent, that is, repeating the same comparison operation O L (E 1 , E 2 ) multiple times always gives the same result (either always wrong or always correct). We shall sometimes assume that p < 1/16 as in prior works [21] in order to apply these results (though our approach/results are generic, in the sense that they can be parameterized by the dislocation of sorting with a generic p or even a generic error model).

Remark 2.
A weaker model would be to allow only comparisons between the weights/distances of two edges, analogously to pairwise comparisons in noisy sorting [11]. Unfortunately, this model seems too weak for the k-medoids clustering problem, since it is not possible to directly compute the optimal centroid of a cluster of more than four nodes. For this reason, we adopt the model that allows for comparing two sets of edges.
Observation 1. One might be tempted to simulate repeated comparisons between two distances, d(x, y) and d(x , y ), via various comparisons of subsets, e.g., d( . Though this is in principle possible, since comparisons are persistent, whenever the underlying algorithm will query the same subset, the answer is the same of that in our "simulated repeated comparison". This happens, for instance, if the algorithm during its execution needs to compare the following two candidate clustering solutions: In this work, we deliberately choose to not attempt any simulation of "repeated" comparison because of this issue. This has the additional advantage that some of our results might be in principle applicable to different error models where costs might be dependent on the sets, or the error probabilities might depend on the distance values involved.

Performance Evaluation
We evaluate the performance of our algorithms by distinguishing between the two types of queries we make: If h(n) is the total number of query to O H and l(n) to O L , where n = |X|, we say that the algorithm has h(n), l(n) high-low cost complexity [11]. Furthermore, we use the standard notation O(·) and write O h(n), l(n) to denote O(h(n)), O(l(n)) , while with O(t(n)) we denote only the total number of high-cost operations (this corresponds to the usual complexity notation where all operations are error free).

Two Algorithmic Tools
We will use two key results related to our error model, namely, sorting with only erroneous comparisons, and approximate solutions for matroids, respectively. Lemma 2 (approximate sorting [21]). Given a sequence S of n elements, and a comparison query that flips the answer with a small probability p < 1/16, there exists an algorithm with the following performance guarantee. For any confidence parameter ∆ > 0, 1.
The algorithm uses O(n log n) low-cost queries only (and no high-cost query). Each query compares a pair of elements, and these low-cost queries have an error probability p < 1/16. These comparison errors are persistent.

2.
The algorithm returns an almost sorted sequenceŜ, where the dislocation of each element is at most O(∆ log n) with probability of at least 1 − 1 n ∆ (the probability depends only on the outcome of the comparisons).
The dislocation of an element x in a sequenceŜ is the absolute difference between the position of x in S and the position of x in the correctly sorted sequence S.
Lemma 3 (approximate matroid [11]). Given a matroid (M, F) and two high-low cost oracles in order to compare the elements of M, it is possible to find an (1 + )-approximation of the optimal base using O 1 (log n) 2 , n log n high-low queries.

Clustering in Stable Instances
In order to describe the algorithms, it is convenient to think of the input (metric space) as the following (complete) induced weighted graph: Definition 2 (induced graph, spanning forests, clustering). Given a metric space (X, d), the induced graph is a complete weighed undirected graph G X = (X, E X , w) where E X = ( X 2 ) and for every edge e = (x, y) we have w(e) = d(x, y). For any tree T spanning all nodes X, and for any subset of edges F = T \ K, let us denote by C (F) the connected components (nodes) of the forest F. These connected components is a k-clustering whenever we remove k − 1 edges from a spanning tree T.
The known optimal polynomial time algorithms for stable clustering are based on the above tree/forest construction. The simplest of such algorithms is the following one.

Single-Linkage (Naive Algorithm):
• Phase 1 (Minimum Spanning Tree): Compute a tree T spanning all nodes X minimizing the overall cost d(T).

• Phase 2 (Remove Edges):
To obtain a k-clustering, remove the subset K of k − 1 edges having a maximum total weight d(K).
It is well-known that this naive algorithm does not achieve any (bounded) approximation guarantee even in our γ-pertubation-stable metric instances [2] (see also [15]). The reason is that the criteria for computing the removed edges K does not directly take into account the cost of the resulting clustering. The following algorithm indeed finds the optimum in several stable clustering problems [1][2][3].

Single-Linkage++ (Correct Algorithm):
• Phase 1 (Minimum Spanning Tree): Compute a tree T spanning all nodes X minimizing the overall cost d(T).

• Phase 2 (Remove Edges++):
To obtain a k-clustering, remove the subset K of k − 1 edges resulting in minimal cost Cost(C (T\K) ).
Both algorithms above consists of two phases, each of them corresponding to solve exactly a matroid problem. Unfortunately, in order to have a small number of high-cost operations (Lemma 3), we have to content ourself with approximate solutions.

Warm-Up: Phase 2 of Single-Linkage Algorithm
In order to describe some difficulties and to convey some basic ideas, we shall first consider implementing Phase 2 of Single-Linkage algorithm only. We thus assume that the (exact) Minimum Spanning Tree (MST) has been already computed (or it is given). Observe that Phase 2 of Single-Linkage algorithm boils down to the problem of selecting the top k − 1 elements from a set of n − 1 edges of the MST, thus a simple matroid. We first observe the following three facts on this task (details below): 1.
There is a naive approach using O(k + (n − k) log k) = O(n log k) high-cost operations in total (and no low-cost operation).

2.
Approximate sorting (Lemma 2) can reduce the total number of high-cost operations Approximate the matroid (Lemma 3) would directly further improve the above bound for some values of k. Unfortunately, this leads to a solution which is far more costly than the one returned by the algorithm with exact comparisons (or with the previous methods).
As we discuss below, though Single-Linkage has no approximation guarantee, we show that, in some stable instances where it would find an optimal solution, the matroids' approximation makes it compute a solution of much larger cost. This suggests that Phase 2 of this algorithm (removing the k − 1 edges) is a "fragile" part of the algorithm (also for the more complex Single-Linkage++). Instead, we show in the next section that the first step (computing the MST) can be done approximately without "destroying" the clustering optimality.
In the remainder of this section, we discuss briefly some details on the three items above.
3.1.1. Naive Approach (all at High Cost) We create a Min Heap with the first k − 1 elements of E T , and then iterate over the remaining ones: Every time an element is greater than the root, we replace the root with this element and we re-balance the tree. Finally, we return all the elements in the Min Heap. This strategy takes O(k + (n − k) log k) high-cost operations.

First Improvement (Combining Low and High Cost Operations)
Using Lemma 2, we can sort the elements in an array using only O(n log n) low-cost operations, and obtain a sequence with maximum dislocation d = O(log n). Having sorted the array in this way, we can restrict to the first m = k − 1 + d, elements (since we know that the k − 1 heaviest elements are in this interval). By applying the previous Min Heap strategy to these m elements, we can find the true k − 1 heaviest edges. This strategy leads to the following slightly more general result, which we shall use below as a subroutine: Lemma 4 (find top-t elements). Given any set of n elements, and any confidence parameter ∆, with probability at least 1 − 1 n ∆ , we can extract the top-t (largest or smallest) elements using O t + ∆ log t log n, n log n high-low cost operations.
Proof. According to Lemma 2, with probability at least 1 − 1 n ∆ , we can obtain a sequence where every element has dislocation at most d = O(∆ log n) using O(n log n) low-cost operations only. To find the t largest elements, we consider the first m = t + d elements and apply the Min Heap strategy to these only. This takes high-cost operations only as observed above. The overall cost is thus The previous lemma yields the following result. Theorem 2. Phase 2 of Single-Linkage algorithm can be implemented using O k + log k log n, n log n high-low cost operations, and its success probability is at least 1 − 1 n .

Matroid Approximations Fail
We can use matroids in order to find the best forest F from which we can generate the k-clustering. In particular, we can consider the matroid M = (E, I), where E is the set of all the edges in the MST T and F = {e ∈ 2 E X ||e| ≤ n − k} is the family of forests that can be obtained by removing exactly k − 1 edges from T. Then, we have that the best forest F is simply the minimum base B of matroid M.
We could then apply Lemma 3 and obtain an (1 + )-approximation of the base using , n log n high-low cost complexity. Note that this would improve significantly the previous bound for k (log n) 2 . Unfortunately, the next example shows that this approach leads to a solution whose cost is unbounded compared to the solution returned by the algorithm.
Example 1 (unbounded error for the approximate matroid strategy). Let us consider instance X consisting of k groups, G 1 , . . . , G k , of m points each and one additional point v. The distance function d has the following values for an arbitrary small > 0 and some very large L: 1.
Distances inside the same group are 0, i.e, for any G i and any two x, y ∈ G i , we have d(x, y) = 0.

2.
Distances between groups are 1 + , i.e, for any two different groups G i and G j , and for x ∈ G i and y ∈ G j , we have d(x, y) = 1 + .

3.
Point v is at distance 1 from points in G 1 and distance L from all other points, i.e., The corresponding minimum spanning tree is composed by k spanning trees inside each group (each with cost 0), a spanning tree of the group composed of exactly k − 1 edges each with cost 1 + and one single edge from G 1 to v. Now, if we use a matroid to find a minimum spanning forest, we will find a correct minimum base B * in which we remove all the k − 1 edges with cost 1 + . This base has a weight of 1 and the cost of the cluster is 1. Now, supposing that we run the (1 + )-approximation algorithm in order to find a minimum base, this gives us a baseB where we remove from the minimum spanning tree k − 2 edges of cost 1 + and the edge with cost 1. This is possible since However, the cost of the corresponding cluster is at least m, since we put two groups in the same cluster.
The above example shows that, even with an arbitrary small approximation, we can have cases where the error in the final solution (clustering) is unbounded.

Phase 1: Compute a "Good" Spanning Tree
In the previous section, we have assumed that we have given a MST T. This task can be solved with the standard MST algorithm using O(n 2 ) high-cost operations. A natural question is thus whether there is a strategy that uses less than o(n 2 ) high-cost operations. This seems difficult if we insist on computing a MST, since any edge in the MST can potentially appear in every position of the sorted sequence of edges.
A key observation is that we do not have to necessarily compute a MST, but we only need a spanning tree from which we can recover the optimal solution removing k − 1 edges. This is captured by the following definition.
Definition 3 (k-spanning tree). Let (X, d) a metric space and let C * 1 , . . . , C * k be an optimal kclustering. A tree T of this metric space is k-spanning if every subtree T[C * i ] induced by C * i is connected.
The definition essentially says that, by removing k − 1 edges from a k-spanning tree, we obtain a forest whose connected components correspond to the optimal solution. Implicit in the proof of [3] (see also [4]), in order to successfully compute the optimum, it suffices to have a k-spanning tree (and not necessarily a MST one). Theorem 3 (due to [3]). The modification of Single-Linkage++ algorithm, where, in Phase 1, we compute a k-spanning tree, finds the unique optimal k-clustering in every γ-pertubation-stable instance, with γ ≥ 2.
We thus consider how to compute a k-spanning tree, instead of an exact MST. We first show the following key corollary of Lemma 1.

Corollary 1.
For any γ-perturbation-stable metric space (X, d), with γ ≥ 2, and with optimal solution C * 1 , . . . , C * k the following holds. If x ∈ C * i and y / ∈ C * i , for some cluster C * i , then it must hold that where c * i is the centroid of C * i .

Proof.
Since y ∈ C * j for some j different from i, we have where the first and last inequality are due to the triangle inequality, and the second inequality follows from Lemma 1. Then, by rearranging the terms, we obtain which implies the corollary after some simplification. Now, we are ready to prove a sufficient condition for a tree to be k-spanning, which we shall use below to derive an algorithm good performance guarantee.
Proof. By contradiction, supposeT is not a k-spanning tree. We show that it cannot be a (1 + )-approximation of the MST T. Since T is not k-spanning, there is an optimal cluster C such thatT[C] is not connected. Let C be a connected component ofT[C] that does not contain the centroid of C. Let x ∈ C be a node that is connected with some other y / ∈ C. Consider the treeT and observe that, for d := d(x, c), we have where the inequality is due to Corollary 1. Since d(T) ≤ d(T), we have that where the last inequality follows from d ≥ d By combining Lemma 5 with Lemma 3 (recall that the MST problem is a matroid), we obtain the following result.

Corollary 2.
For any γ-perturbation-stable metric space (X, d) , with γ > 2, a k-spanning tree can be computed using O n log 2 n (γ−2)w , n log n high-low cost operations with w = Proof. By Lemma 5, it is enough to compute a (1 + )-approximate MST with = (γ−2) n w. Since the MST is a matroid, Lemma 3 implies the result.

Remark 3.
Note that the result above depends the values of w and γ. This result provides an alternative method for computing a k-spanning tree, which, in some cases, can be more efficient than using O(n 2 ) high-cost operations for computing a MST. In particular, the bound in Corollary 2 is better for We conclude this section by observing that, in a sense, the above approach cannot be easily improved. In particular, it might be desirable to extend Corollary 2 to some small but constant > 0, which would improve the bound and also do not require any knowledge about w and γ. Unfortunately, the following lemma provides a negative answer. Intuitively, this is because the cost of the MST and the cost of the optimal clustering may be very different.
Lemma 6 (limitations of approximate MST). For every > 0, there exists a metric space (X, d) such that, even if we find a spanning treeT, which is an (1 + )-approximation of the MST T, this treeT is not k-spanning. In particular, for every subset K of k − 1 edges ofT, the corresponding clustering has an unbounded error.
Proof. Letting > 0 be arbitrary, we consider the following set of points located on the 1-dimensional Euclidean space: where L 1 is an arbitrary positive number and L 2 = 1 L 1 . We take d as the Euclidean distance (i.e., the absolute difference between these numbers) and consider k = 3 clusters.
Note that the cost of the MST T is d(T) = 3 + L 1 + L 2 and the cost of the optimal cluster C is d(C) = 3. Now, consider the treeT obtained by replacing in T edge (−L 1 , −L 1 − 1) with edge (0, −L 1 − 1). The cost of this new treeT is and we can see thatT is not k-spanning since T[{L 1 , −L 1 − 1}] is not connected. SinceT contains three edges of cost L 1 , L 1 + 1 and L 2 ≥ L 1 , removing any two edges fromT has a cost d(Ĉ) ≥ L 1 . Therefore, the approximation guarantee is at least d(Ĉ) d(C) ≥ L 1 3 , which can be made arbitrarily large by increasing L 1 in this construction.

Phase 2 of Single-Linkage++ (Removing the Edges)
In this section, we focus on Phase 2 of the algorithm Single-Linkage++, namely, computing the subset set K * of k − 1 edges whose removal (from the tree T computed in Phase 1) yields the (unique) optimal clustering. This phase can also be seen as a matroid, though it is more complex than the one of the Single-Linkage (naive) algorithm because of these two issues:

1.
In order to evaluate the cost of a candidate solution (set K of edges to remove), we need to compute the centroids of each cluster; 2.
The number of elements in the associated matroid is N = ( n−1 k−1 ), though we are interested in extracting only one (the optimal K * ).
Another caveat is that, since we shall try all N = ( n−1 k−1 ) subsets, in order to ensure a correct answer with high probability, we need for the subroutine determining the "correct" centroids to succeed with sufficiently high probability. Definition 4. An (α, q)-centroids procedure is an algorithm, which, on inputting any optimal k-clustering C 1 , . . . , C k , with probability at least 1 − q returns a tuple (c 1 , . . . ,c k ) = centroids(C 1 , . . . , C k ) of α-approximate centroids, For α = 1, we have an exact centroid procedure that returns the optimal centroids c i of each cluster C i .

Definition 5.
Given a k-spanning tree T, an α-approximate removal is a subset of k − 1 edges such that the k-clustering obtained by removing these edges from T is α-approximate.

Theorem 4.
Suppose there exists an (α, q)-centroids procedure centroids using O h CEN , l CEN high-low operations. Then, there exists an algorithm, which, with probability at least 1 − q − 1 N , finds an α-approximate removal using O Nh CEN + log N, Nl CEN + N log N high-low operations in total.
Proof. Given any k-spanning tree T, we simply try all possible candidate subsets K of k − 1 edges of T, and find the one that corresponds to the optimum as follows. For each candidate subset K (a) , with a = 1, . . . , N, we proceed as follows: 1.
Consider the corresponding clustering C k . This can be done by simply inspecting the nodes of each connected component when removing edges K (a) from T.

2.
Run the procedure centroids to compute (some) centroids for this candidate clustering, We now observe two key properties of these (candidate) centroids. For each cluster C (a) i , consider the sum of the distances to its candidate centroid c (a) i , and observe that i may not be the optimal centroid for C (a) i . Moreover, for the optimal K (opt) and the corresponding optimal k-clustering C  satisfies and therefore d(E (opt) ) ≤ αCost(C (opt) ) .
This implies that the candidate K (min) = arg min K (a) d(E (a) ) which minimizes d(E (a) ) among the N candidates is indeed an α-approximate removal: The total high-low cost to create the list of all N elements is O Nh CEN , Nl CEN . As observed above, with a probability of at least 1 − q, the minimum in this list yields an α-approximate removal. Each pairwise comparison between two elements, say d(E (a) ) and d(E (b) ), can be done with a single call to our oracles, either O L (E (a) , E (b) ) or O H (E (a) , E (b) ). We can thus apply Lemma 4 and, with a probability of at least 1 − 1 N , find the minimum element using log N, N log N high-low cost operations. The overall high-low cost to find an α-approximate removal is thus Finally, by the union bound, the probability that we actually find an α-approximate removal is at least 1 − q − 1 N .
From the previous result, we can focus on constructing a suitable procedure centroids.

Exact Centroids and Exact Solutions
We begin by considering procedures to compute exact centroids (α = 1), which automatically lead to optimal k-clustering. The first (naive) approach is simply to use only high-cost (exact) operations.
All at High-Cost.
We want to find an implementation of centroids using only high-cost operations. For each cluster C i , and two candidate points x, y ∈ C i , we can compute and, by calling O H (E x , E y ), we can decide which of these two points is a better centroid. By repeating this for all the points in one cluster, and for all the clusters, we can find the optimal k centroids using only O(n) high-cost operations in total. This shows the following.
Observation 2. The best subset K * can be found using O Nn, 0 high-low operations in total, where N = ( n−1 k−1 ).
We next investigate how to reduce the number of high-cost operations by introducing low-cost ones (still aiming for exact centroids).

Using low cost operations
Similarly to what we discussed above, our low-high cost operations are calls to our oracles O L (E x , E y ) and O H (E x , E y ), where x, y ∈ C i and E x , E y are as in (3). According to Lemma 4, for each cluster C i consisting of n i = |C i | elements, we can find its optimal centroid (the minimum) using O ∆ i log n i , n i log n i high-low cost operations with a probability of at least 1 − 1 n i ∆ i . In order to optimize the overall success probability, we set for a suitable ∆ independent of i. The resulting procedure centroids has the following performance guarantees:

1.
Success probability at least 1 − k/n ∆ . For each cluster C i , the probability of finding the optimal centroid is at least 1 − (1/n) ∆ since n ∆ i i = 2 ∆ i log n i = 2 ∆ i log n = n ∆ . By the union bound over all k clusters, the success probability is at least 1 − k/n ∆ .

2.
High-cost operations O k log n k . The total high-cost of centroids for computing all centroids of any given partition C 1 , . . . , C k of X is

3.
Low-cost operations. We observe that this is where these bounds can be easily obtained using the Lagrange Multiplier.
Observation 3. The best subset K * can be found using O N(k log n) 2 , Nn log n k high-low operations in total, where N = ( n−1 k−1 ). In the next section, we shall reduce significantly the high-cost by introducing an approximate computation of the clusters which uses zero high-cost operation. We shall see that this results in a (small) factor approximation in the solution.

Approximate Centroids and Approximate Solutions
As we have seen in the previous section (Remark 4), it is quite easy to reduce the number of high-cost queries used to find the best subset once we have computed the function centroids for every partition. The problem is that, even if we improve the highcost cost of the function centroids to be a constant, since we apply it to O(N) different partitions, we still have in total an expensive high-cost. For this reason, we now consider a method to compute approximate centroids without using any high-cost operation, that is, an approximate implementation of centroids with only low-cost operations.
Though this may not give us an exact solution, we shall prove that this shall lead to a 2-approximate clustering. The next result is central for this section.
Lemma 7 (centroid approximation). Given a metric space (X, d), for any cluster C i ⊆ X, and for any x ∈ C i , it holds that where n i = |C i | and D i (x) is the number of points y in C i which are a better centroid than x, Proof. Let c * i = arg min z∈C i Cost(C i , z) be the optimal centroid of C i and the corresponding optimal cost is O = Cost(C i ) = Cost(C i , c * i ). Observe that, for every c i ∈ C i , we have , and let us partition C i into the following two sets: By definition |H − | = D i (x) and |H + | = n i − D i (x). Moreover, for any y ∈ H + , we have thatÔ Using the fact that the distances between two points are nonnegative, we get the following lower bound on the optimal cost of the cluster, and, by rearranging the terms, we obtain which completes the proof.
Intuitively, by combining the lemma above with Lemma 2, our approximation depends on the dislocation D i (x) that the sorting procedure (using only low-cost operations) guarantees when applied to the n i = |C i | elements of cluster C i . This leads to the following result.

Lemma 8.
For any parameter ∆ ≥ 0, there exists an (α, q)-centroids procedure with using O 0, n log n high-low cost operations, with q ≤ k · n −∆ and where n min is the size of the smallest cluster in the optimal k-clustering C 1 , . . . , C k , that is, n min = min i {n i } for n i = |C i |.
Proof. We choose ∆ i as in the previous subsection, eq. (4), so that ∆ i log n i = ∆ log n for a fixed ∆ ≥ 0 independent of i. By Lemma 2, for each cluster C i , with probability at least n). By the union bound, the overall probability of computing such points for all k clusters is at least 1 − k · n −∆ , hence q = k · n −∆ . Note also that we use only low-cost operations, in particular, the total low-cost operations are ∑ k i=1 O(n i log n i ) = O(n log n). We next argue about the approximation guarantee. By Lemma 7, for each cluster C i , the corresponding centroid x of our procedure satisfies The latter is maximized when n i is the smallest, that is, for n i = n min = min i {n i }.

Dynamic Programming
A dynamic programming to find the best clustering giving a k-spanning tree can be found in [3]. In this section, we shall simplify their dynamic programming (which works for a more general class of problems) in order to adapt it to our oracles model.
In general, it is rather difficult to work with "approximate" solutions with dynamic programming, since the errors accumulate during the execution of the algorithm, and we do not have a clear way to control this (for a rare example, a dynamic programming algorithm working with errors, see [31]). Therefore, our approach will be to always produce correct intermediate results, while still trying to limit the number of high-cost operations.

Basic Notation and Adaptations
First of all, observe that the algorithm in [3] applies to a more general problem in which we have a generic function g(u, d) applied to the distance function d, and a function f (c) that indicates the cost of having c as a centroid. Therefore, we instantiate these two functions according to our problem, that is, we consider g(u, d) ≡ d and f (c) ≡ 0.
Before starting with the actual algorithm, we have to transform our tree T X = (X, E X ) in a binary tree B X = (V B , E B ) using the procedure described in [3] (select an arbitrary node as the root and then add nodes in a top-down fashion to get a binary tree). In the following, we use X as the set of the original points and U as the set of the points that we add so that V B = X ∪ U. One can easily check that, for a node x that has c(x) children, we have to add c(x) − 2 nodes if x has more than two children and one if c(x) equals one. Note that the number of nodes is |V B | = |X ∪ U| = O(n), and thus we can still denote with n the input size and count the number of queries as a function of n.
We define L the set that contains all the leaves of B X , and we create two sequences S and S of the nodes in reverse breadth first order from the root, where S contains only the non leaf nodes.
Then, we build a data structure Cost where, at each key (u, j, c), we encode information to evaluate the optimal solution for partitioning the subtree B u rooted at u into j ≤ k clusters with c being the centroid of node u (here B u is the set of nodes in subtree rooted at u). In particular, for every key (u, j, c), the data structure Cost contains a set E(u, j, c) of edges of the tree that represents the connections of nodes in subtree B u to their clusters in that particular solution, and an integer variable s(u, j, c) that represents how many of these centers are from U, and thus how "illegal" is the solution (we have to add this variable since we set f to be always equal to zero). This is in contrast with the original dynamic programming in [3], where we associate only a single integer to every key.
The last thing we have to do is to modify the output of the algorithm. In [3], it how to compute the total cost of the perfect clustering is the only thing mentioned. This of course can not be done with our model since we have no information about the absolute distance between the points. Thus, we have to further modify it in order to obtain the cluster centroid as output of the algorithm, so that we can easily compute the cluster by associating each point to the closest centroid. In order to achieve that, we create a second data structure Centroid indexed by keys (u, k, c), where each entry contains a set of the best centroids for partitioning the sub tree rooted at u in k clusters.

The Actual Algorithm
We are now in a position to describe the dynamic programming algorithm based on the binary tree B X and the two data structures described above.

Initialization
Similarly to [3], we have to initialize the leaves. In particular, we associate in the data structure Cost, for each key (u, 1, c), where u ∈ L and c ∈ X, a list that contains only the edge (u, c) and the variable s is set to 1 if c ∈ U, and zero otherwise. For all the key (u, j, c), with u ∈ L, c ∈ X and j > 1, we associate an empty set and 1 to the variable s. Furthermore, in the second data structure Centroid, we associate an empty set to all the previous keys.

The Algorithm
We traverse the key in the order for j from 1 to k, for node u ∈ S and c ∈ S, and we compute the optimum for each key (u, j, c). In the original dynamic programming [3], this is done by searching for the couple (l, j 1 , c 1 ) + (r, j 2 , c 2 ) that corresponds to the best value, where l and r are the two children of u in the binary tree. Since we do not have access to the individual value for a couple of keys, we create a list containing all possible couples (l, j 1 , c 1 ) + (r, j 2 , c 2 ), and then we extract the best solution. In order to perform the latter task, we have to be able to compare two candidate couples for the same left and right child l and r, say (l, j 1 , c 1 ) + (r, j 2 , c 2 ) and (l, j 1 , c 1 ) + (r, j 2 , c 2 ) .
We show that this can be done by using a single call of our oracle in the following way. For a generic couple, (l, j 1 , c 1 ) + (r, j 2 , c 2 ), the data structure associated with the two elements of this couple consists of (E(l, j 1 , c 1 ), s(l, j 1 , c 1 )) = Cost(l, j 1 , c 1 ) (E(r, j 2 , c 2 ), s(r, j 2 , c 2 )) = Cost(r, j 2 , c 2 ) To express the dynamic programming, it is useful to introduce the following auxiliary functions depending on (u, c): We are now in a position to express how to choose between the two couples in (5). Consider E = E((l, j 1 , c 1 ) + (r, j 2 , c 2 )) s = s((l, j 1 , c 1 ) + (r, j 2 , c 2 )) − f c,c 1 − f c,c 2 E = E((l, j 1 , c 1 ) + (r, j 2 , c 2 )) s = s((l, j 1 , c 1 ) + (r, j 2 , c 2 )) − f c,c 1 − f c,c 2 If s = s , then we choose the couple corresponding to the minimum between these two values. If instead s = s , then we evaluate the corresponding cost by performing an oracle query to E and E after removing all edges incident to some point in U. In this case, we return the couple with a minimum cost.
The above criterion extends naturally to subsets of couples, and it will replace the basic 'min' operation in the original dynamic programming formulation [3].
Having determined the optimal couple (l, j * 1 , c * 1 ) + (r, j * 2 , c * 2 ) for the key (u, j, c), we set the corresponding content of data structures Cost and Centroid as follows: After we have filled all possible keys (u, j, c), we simply have to find the best value of c * among all keys (root, k, c) using the same method, and return the set associated with Centroid(root, k, c * ).

Analysis of High-Low Cost
The total running time is given by the central part of the algorithm. Let u,j,c be the length of the list that contains the candidate couples associated with the key (u, j, c). We have to extract the minimum every time, which can be done using O log , log the high-low cost, for = u,j,c (Lemma 4). Since the length u,j,c is O(j|B u l ||B u r |) = O(kn 2 ), and the overall high-low cost is O log(kn 2 ), kn 2 log(kn 2 ) = O kn 2 log n, k 2 n 4 log n .
Though the high-cost is worse than the previous result, for k large, this bound is exponentially better in terms of low-cost. Finally, observe that we can invoke Lemma 4 with parameter ∆ = Θ(log n) so that each of these operations fails with a probability of at most n −a for sufficiently large a, so that the overall procedure succeeds with high probability (union bound), and the overall complexity is as above (again using u,j,c = O(kn 2 )).

Same Cluster Queries
In this section, we investigate so-called same-cluster queries: Given two points in our metric space (X, d), the corresponding same-cluster query returns "yes" if and only if the two points are in the same cluster in the optimal solution. Of course, this type of query is extremely powerful, though rather difficult to implement in general. In Section 4.1, we first show that, under certain conditions, we can simulate same-cluster queries in our model. In Section 4.2, we present algorithms which find the optimal k-clustering using "few" same-cluster queries-these use "black-box" and thus the algorithm can be applied to any setting where such queries are available but perhaps even more expensive than comparisons in our model.

Small-Radius and Same-Cluster Queries
Observe that Corollary 1 says that, if two points are not in the same cluster, then their distance must be larger than (γ − 1) times the distance of one point to its optimal centroid. This condition does not automatically give a same-cluster query because it requires the knowledge of the optimal centroids, and it does not give an 'if and only if" characterization. As we show below, under some additional assumptions, we can obtain a characterization for two points being in the same cluster which does not involve the optimal centroids (see the next definition and lemma). This in turn implies that we can build a same-cluster query.
Definition 6 (γ-radius optimal clusters). Let d (centroid) max be the maximum radius of the clusters in the optimal solution, that is, d is the centroid, the cluster containing x in the optimal solution. We say that a γ-perturbation-stable metric space (X, d) has γ-radius optimal clusters if y) is the minimum distance between two points. Lemma 9 (same cluster condition). For any γ-perturbation-stable metric space (X, d) which has γ-radius optimal clusters, with γ ≥ 2, the following holds. For every x, y ∈ X, where C * 1 , . . . , C * k is the optimal solution.
Proof. We first prove the (⇒) direction: where C * i(x) and c * i(x) are the cluster and the centroid of x in the optimal solution, respectively, and the second implication is given by the contrapositive of Corollary 1.
In order to prove the other direction (⇐), consider arbitrary x and y in the same cluster with centroid c * and observe that where the first inequality is by triangle inequality (metric space) and the second by the γ-radius optimal clusters assumption (Definition 6).

Implementing a Same-Cluster Query
According to Lemma 9, our same-cluster query, upon inputting two points x and y, is simply checking whether d(x, y) ≤ (γ − 1)d (X) min holds. We are now in a position to construct our same cluster query. In order to do so, we shall allow more general queries to compare pairwise distances multiplied by scalars, that is, for any two pairs of points e 1 = (x 1 , y 1 ) and e 1 = (x 2 , y 2 ). The cheap but erroneous counterpart O (α) L (·) is defined similarly, and its answers are wrong with the same probability p ≤ 1/16 as in our oracle O L (·). Observe that we can check whether d(x, y) ≤ (γ − 1)d (X) min by one call to the above oracle with e 1 = (x, y) and e min = arg min x =y d(x , y ) being from the pair of points at a minimal distance, d (X) min = d(e min ). Lemma 9 thus implies the following: Lemma 10. For every γ-perturbation-stable metric space (X, d) which has γ-radius optimal clusters, γ ≥ 2, the following query is an exact same-cluster query, where e min = arg min x =y d(x , y ). The analogous cheap but erroneous query SCQ ((x, y), e min ) is a same-cluster query that is correct with probability at least 1 − p.
Note that these queries are similar to those used in [8,9], though these works consider "triples" of points, e 1 = (x, y) and e 2 = (x, z), and the error model is different. We next discuss how expensive is to build such queries and whether they can be built based on our initial query model.

Observation 4.
Observe that the pair of points e min = arg min x =y d(x , y ) can be determined once and for all using O log n, n 2 log n high-low cost (Lemma 4). Therefore, any algorithm using SCQs only requires this additional high-low cost to be implemented.

Observation 5.
For γ = 2, the above query is a simple query between distances. Moreover, for any integer γ ≥ 2, the query can be simulated by considering a multiset of pairs: where E γ consists of γ − 1 copies of e min .
Assuming an oracle like in (6) is available, and each exact/erroneous SCQ corresponds to one high/low cost operation. Alternatively, if we allow multiset comparisons in our original oracle model, the same also holds true (without directly appealing on the oracle in (6)). Finally, for γ = 2, we simply can use the original oracle.

Remark 5.
Though every γ-perturbation-stable instance with γ ≥ 2 is also 2-perturbation-stable instance, since we require the additional 'γ-radius optimal clusters' condition there might be instances that satisfy the hypothesis to obtain SCQs above only for some γ > 2.
In the sequel, we shall devise algorithms that attempt to use as few as possible SCQs. In their analysis, we shall then account explicitly for the overall number of such queries and the rest of high-low cost operations derived from queries to our original oracle model. Whenever the original oracle model suffices to simulate the SCQ H and/or SCQ L , each SCQ corresponds to a single operation (high or low cost).

An Algorithm Using Few SCQs
We next describe a simple algorithm which uses much less SCQs, though a comparable number of high-low cost operations. The algorithm works for certain instances, and its performance is summarized in the following theorem.
Theorem 5. For any γ ≥ 2 and for any positive integer n 1 , there exists an algorithm with the following performance guarantees. The algorithm computes the optimal k-clustering, with a probability of at least 1 − 3 n , on input any γ-perturbation-stable metric space (X, d) which has γ-radius optimal clusters, and such that every cluster in the optimal solution has a size of at least n 1 . Moreover, the algorithm uses only the following number of exact same-cluster queries and high-low cost operations parameterized in p 1 = n 1 n : 1.
The algorithm uses O( k log k p 1 ) exact same-cluster queries, which is independent of n for approximately balanced clusters, that is, n 1 = Θ(n/k).

2.
The additional high-low cost operations used by the algorithm is O (log n) 2 p 1 , ( log k p 1 + n)k log n .

The Algorithm
We first observe that Corollary 1, in addition to the condition used to simulate samecluster queries in Lemma 9, implies another useful property that we can use to reduce the number of high-cost queries. Intuitively, under the same conditions of Lemma 9, we have that every point is closer to all points in its own cluster than to any of the points outside.

Corollary 3.
For any γ-perturbation-stable metric space (X, d) that has γ-radius optimal clusters, with γ ≥ 2, the following holds. For every optimal cluster C * , every x, y ∈ C * and z / ∈ C * , it holds that d(x, y) < d(x, z).
Proof. Let x, y, z be arbitrary points of X, with x, y in the same cluster C * with centroid c * . Then, we have that where the last inequality is given by Corollary 1.
Remark 6 (main intuition). Corollary 3 means that, in order to identify a cluster C * i , instead of its optimal centroid, we can simply determine an arbitrary point x i and assign this point as a (representative) centroid of that cluster C * i , for all k clusters. Then, we can map every other points to the closest (representative) centroid. and, more in general, the following upper bounds hold (see [32]) where H k is the k-th harmonic number.
Lemma 12. The expected number of exact SCQs in Step 1 of the Coupon-Collector Clustering algorithm is O(kC(p)), where p = (p 1 , p 2 , . . . , p k ) is given by p i = n i /n and n i = |C * i |, and C * 1 , . . . C * k being the optimal k-clustering, Proof. We simply observe that, for each point, we extract from X that the probability that it belongs to cluster C * i is n i /n = p i . Moreover, for every newly picked point, we have to perform a same-cluster query SCQ H with the centroid of each cluster that we have already found in order to be sure that the new point belongs really to a new cluster. This costs at most the number of clusters k.

Analysis of the Second Step
In this step, we exact points without replacements. The analysis is essentially based on the generalization of the CCP problem in which we want to obtain C ≥ 1 copies of each of the k coupons. This problem is known as the double Dixie cup problem [33,34]. The variant in which points are chosen without replacement has been recently used for a similar clustering problem in [30]. We borrow their concentration result: Lemma 13 (Theorem 3.3 in [30]). For any subset of k clusters of size n 1 ≤ n 2 ≤ · · · ≤ n k , the following holds. Suppose m points are sampled uniformly at random without replacement from X. Denote S i as the number of samples filled in cluster i after this process. Then, the probability that each cluster is filled with at least C = mp 1 2 points is bounded as where p 1 = n 1 n and n 1 is the size of the smallest cluster among the clusters under consideration.

Corollary 4.
For any C ≥ 8 log n, by sampling at least m = 2C/p 1 = 2Cn/n 1 , the probability that in every cluster we have selected at least C points is at least 1 − k n 2 ≥ 1 − 1 n .
Given that in each each cluster we select at least C points, the only thing that we have to do is to map all selected points to their correct clusters. For an arbitrary point x, we have to find the closest centroid. By Lemma 4, this requires O ∆ log k, k log k high-low cost for each point x, and the probability of success is at least 1 − 1 k ∆ . By the union bound, all m = Θ( n log n n 1 ) points are then mapped to the correct cluster with probability at least 1 − m k ∆ . Therefore, by Corollary 4, the union bound implies that Phase 2 terminates with at least C points in each cluster of the optimal solution with a probability at least 1 − 1 n − m k ∆ . For ∆ = log(nm) log k , we have m k ∆ = 1 n and the previous probability is at least 1 − 2 n . Moreover, the total high-low cost of this step is and since m = Θ( n log n

Remark 7.
Similarly to what was done in the previous sections, one might think of using no high-cost operations at all, by introducing some approximation. In this case, however, this would mean to assign a point to an incorrect cluster. This might be a problem since assigning a point even to the second closest centroid may result in an unbounded error.

Analysis of the Third Step
Recall that every point is closer to all the points in its optimal cluster than to any point outside that cluster (Corollary 3). Since we have found C centroids for each cluster, for every remaining point x, we can assign it to a cluster using a simple "majority voting" using only low-cost operations. Specifically, for any two clusters and two corresponding centroids, say y ∈ C * i and z ∈ C * j , we use a low-cost comparison to check whether d(x, y) < d(x, z). Fix a subset of C ≤ C of centroids in each of the k clusters. Let W ij denote the number of "wins" of C * i vs C * j , that is, the number of pairs of fixed centroids (y, z) with y ∈ C * i and z ∈ C * j such that the low-cost comparison 'd(x, z) > d(x, y)' is correct (i.e., the strict inequality holds according to Corollary 3). Since W ij is the sum of N = ( C 2 ) Bernoulli random variables such that Pr[X e = 1] ≥ 1 − p, standard Chernoff bounds imply the following: Lemma 14. For C * i being the correct cluster of x and any other cluster C * j , where N = ( C 2 ), and f p is a constant depending on p ∈ (0, 1/2) only.

Proof.
For µ = E[W ij ] ≥ (1 − p)N and for δ = 1 − 1 2(1−p) , we have (note that δ > 0 since p < 1/2) where the first and third inequalities are from µ ≥ (1 − p)N and the second inequality is the Chernoff bound. Finally, note that By the union bound, the probability that the correct cluster C * i of x wins against all other clusters is at least 1 − ke −N f p . In particular, since in the previous step we have chosen C = Ω(log n), we can choose a suitable C = Θ( √ C) = Θ( log n) such that N = ( C 2 ) ≥ 3 log n f p = Ω(log n) and the fail probability is bounded as ke −N f p ≤ 1/n 2 . In order to find the optimal cluster for x, we use a simple "tournament" where we compare the current best cluster with the next one that we did not yet consider. Comparing two clusters costs O(N) = O(C) comparisons, and thus overall we use O(kC 2 ) low-cost operations only for every x. Putting things together, we have the following: Observation 7. In Step 3, with a probability of at least 1 − 1 n , all points are assigned to their optimal clusters using O(knC) = O(kn log n) low-cost operations only.

2.
The additional high-low cost operations used by the algorithm is O k log n + log k p 1 , kn log n . (11) If the size of the smallest cluster is known, then the high-low cost upper bound in (7) also applies.

Conclusions, Extensions, and Open Questions
In this work, we have shown algorithms for clustering that use a suitable combination of high-cost and low-cost comparison (ordinal) operations on the underline distance (dissimilarity) function of the data points. Some of the results are based on a popular graph-based Single-Linkage algorithm at its enhanced version Single-Linkage++ which has provable optimal performance in γ-pertubation-stable instances [1][2][3]. Our results apply to k-medoids clustering, and use comparisons between groups (sum) of distances according to (1). Though this is a rather rich model, and some of these queries may be difficult to realize in practice, some of the results can be extended to simpler queries as we explain below (in fact, the simpler Single-Linkage algorithm uses very simple queries, and the two algorithms differ only in the edge-removal step-Phase 2). The second set of results we provide are algorithms that make use of a rather limited number of exact same-cluster queries, in addition to the comparison high-low cost operations of our model. For example, for instances where the smallest optimal cluster has size n 1 = Ω( n k ), there is an algorithm using O(k log k) same-cluster queries, O(k log 2 n) high-cost operations, and O(kn log n) low-cost operations (Theorem 5 and Theorem 6 provide general trade-offs and also deal with the case n 1 not being known, respectively).
In the remainder of this section, we shall discuss further (possible) extensions of our results, including different query models and different error models that can be considered. We conclude with a discussion on interesting open questions and their relation to the above aspects.

Query Model
Some of our algorithms use only certain types of queries. In particular, we have the following: • While Phase 1 of the algorithm seems already quite expensive in terms of high-cost operations, we note that it makes use of much simpler queries "d(x, y) > d(z, w)?" like in [14]. This is also the case for the Single-Linkage algorithm (Phase 2 naive), which uses very few such high-cost queries (Table 1). While our implementation combines exact (high-cost) and noisy (low-cost) queries, the algorithms in [14] use only noisy queries, though under a different noisy model related to certain planted instances. • The first exact implementation of Single-Linkage++ (Phase 2) requires computing/ estimating the cost of the clusters given their centroids (3). Instead, the dynamic programming version makes use of the full power of the model. Indeed, our approximation (Phase 2 APX in Table 1) is based on the idea that queries/algorithms that approximately compute the centers (medois) are enough. Definition 4 and Theorem 4 suggest that a query model/algorithm which allows for approximating the centers, and their costs (3), yields an approximate implementation of Phase 2 of Single-Linkage++. • The Coupon-Collector Clustering algorithm using same-cluster queries (Section 4) uses very simple comparison-queries, namely "d(x, y) < d(x, z)" (second and third steps), in addition to the same-cluster queries (first step). The latter can either be available or can be simulated by a richer class of "scalar" queries in (6). As already observed, these are slightly more complex than those in [8,9]. • The model can be refined by introducing a cost dependent on the set of distances involved, e.g., how many they are. Whether comparing just two pairwise distances is easier then comparing groups of distances seems to depend on the application at hand; sometimes comparing groups is easier because they provide a richer "context" which helps.

Error Model
• Our error model assumes constant (and independent) error probability across all comparisons. Other error models are also possible and they typically incorporate the "distance values" in the error probabilities (very different values are easier to detect correctly than very close ones). Examples of such models can be found in, e.g., [6,9]. • Different error models may result in different (perhaps better) dislocation bounds on the approximate sorting problem (Lemma 2). This may directly improve some of our bounds, where the maximum dislocation is the bottleneck for finding the minimum (or top-k-elements) with high probability (if the maximum dislocation becomes D log n, then we need O(D ) log n high-cost operations for the latter problem, which is used as a subroutine in most of our algorithms).

Open Questions
The results and the above considerations suggest a number of natural (still open) questions.

•
Reduce the high-cost complexity of Phase 1 of Single-Linkage++. We notice that, in the analysis, the same cluster is considered several times when trying all N = ( n−1 k−1 ) edge-removals. A possible direction might be to estimate the number of partitions of a given (spanning) tree, though this problem does not seem to have a general closed form solution [35]. • Our counterexample shows that a direct improvement of Phase 2 solely based on approximate minimum-spanning tree is not possible. We feel that a finer analysis based on some combinatorial structure of the problem might help. • Extend the results to other center-based clustering problems for which the Single-Linkage++ algorithm is optimal [3]. Our scheme based on approximate centers (Definition 4 and Theorem 4) suggests a natural approach in which we simply need queries that approximate the costs.