Efficient Algorithms For The One-Dimensional K - Center Problem
Efficient Algorithms For The One-Dimensional K - Center Problem
k-Center Problem⋆
1 Introduction
We study the weighted k-center problem for a set of n points on a real line.
Let P = {p1 , p2 , . . . , pn } be a set of n points on a real line L. For each i
with 1 ≤ i ≤ n, the point pi ∈ P has a weight w(pi ) ≥ 0. For a point p on
L, denote by L(p) the coordinate of p on L, which we also refer to as the L-
coordinate of p. For two points p and q on L, let d(p, q) = |L(p) − L(q)| be
the distance between p and q. Further, for a set F = {f1 , f2 , . . . , fk } of points
and a point q on L, define d(q, F ) = d(F, q) = min1≤j≤k d(q, fj ). Given P
and an integer k > 0, the weighted one-dimensional k-center problem seeks
⋆
D.Z. Chen’s research was supported in part by NSF under Grant CCF-1217906.
H. Wang’s research was supported in part by NSF under Grant CCF-1317143.
⋆⋆
This work was partially done while the author was visiting at IIIS at Tsinghua
University.
to determine a set F = {f1 , f2 , . . . , fk } of k points on L such that the value
ψ(P, F ) = maxpi ∈P (w(pi ) · d(pi , F )) is minimized. We use 1DkCenter to denote
this problem. Also, the points in F are called centers, and the points in P are
called demand points.
The unweighted version of 1DkCenter is the case where all points have the
same weight. If F ⊆ P is required, then the case is called the discrete version.
Although many variants of the k-center problem are NP-hard [1,4,15,18,22],
some special cases are solvable in polynomial time. Megiddo and Tamir [22] pre-
sented an O(n log2 n log log n) time algorithm for the weighted k-center problem
on a tree of n nodes, and the running time can be reduced to O(n log2 n) by ap-
plying Cole’s parametric search [10]. Later, Frederickson [14] gave a linear time
algorithm for the unweighted k-center problem on a tree. Jeger and Kariv [17]
gave an O(kn log n) time algorithm for the weighted k-center problem on a tree.
For the weighted k-center problem on a real line (i.e., the problem 1DkCenter),
Bhattacharya and Shi [2] recently proposed an algorithm with a time bound lin-
ear in n but exponential in k. In addition, the discrete weighted k-center problem
on a tree is solvable in O(n log2 n) time [23] and the discrete unweighted k-center
problem on a tree is solvable in O(n) time [14]. The discrete weighted 1DkCenter
has been solved in O(n log n) time [23], without using the parametric search in
[10]. Note that our problem 1DkCenter is the “non-discrete” weighted version.
As indicated by Tamir [24], the problem 1DkCenter can be solved in O(n log n)
time by combining the techniques given by Megiddo and Tamir [22] and Cole’s
parametric search [10]. Although the approach in [22] is elegant and simple,
Cole’s parametric search [10] is quite complicated and involves large constants,
and thus is mainly of theoretical interest. In this paper, we present another
O(n log n) time algorithm for 1DkCenter, which is much easier and avoids Cole’s
parametric search [10]. Further, if all points in P are given sorted on L and
their weights are also sorted, our algorithm can solve 1DkCenter in O(n +
k 2 log2 nk log n log log n) time, which is in favor of small k. For example, if k =
O(n1/2−ǫ ) for any ǫ > 0 (which is true in many applications), our algorithm runs
in O(n) time. It should be noted that if the points in P are given sorted on L,
then the unweighted 1DkCenter is solvable in O(k 2 log2 n) time [24]. In addi-
tion, our techniques also yield an efficient data structure for processing queries
for finding a lowest point in the common intersection of a certain subset of half-
planes, which we call the 2-D sublist LP queries. Since the 2-D sublist LP query
is a basic geometric problem, our data structure may be interesting in its own
right.
2
Chen and Wang [6] proposed another O(n log n) time algorithm without using
parametric search, by modifying the slope selection algorithms [3,19]. Although
the algorithm in [6] avoids the parametric search, it is still complicated and not
practical because it involves the techniques of either cutting [3] or expanders
[19]. In addition, Liu [20] presented an O(n log n) time randomized algorithm
for this points approximation problem.
In fact, we model 1DkCenter as a special case of the above points approx-
imation problem such that we are able to develop a simple and deterministic
O(n log n) time algorithm. Further, we can solve the problem in O(n) time
in some special situations, as discussed earlier. Specifically, after the geomet-
ric transformations, a key component to solving the problem is the follow-
ing 2-D sublist LP query problem: Given a set of n upper half-planes, H =
{h1 , h2 , . . . , hn }, in the plane, for each query q(i, j) (1 ≤ i ≤ j ≤ n), compute a
lowest point p∗ in the common intersection of all half-planes in Hij = {ht | i ≤
t ≤ j}. A data structure was proposed in [7] for this problem, which can be built
in O(n log n) time and answers each query in O(log2 n) time. On the 1DkCenter
problem, we observe that the input half-plane set H has a special property that
the intersections between the x-axis and the bounding lines of the half-planes
are ordered from left to right according to the half-plane indices in H. Exploiting
this special property and using the compact interval trees [16], we design a new
data structure for this special case of the 2-D sublist LP queries, which can be
built in O(n log n) time and can answer each query in O(log n) time. This new
data structure allows us to solve 1DkCenter in O(n log n) time, and in O(n) time
in certain situations. Further, since the 2-D sublist LP query problem is a very
basic problem, our new data structure may find other applications as well.
In the following, we present the high-level scheme of our algorithm in Section
2. In Section 3, we model our problem as the 2-D sublist LP queries and present
our data structure. Section 4 concludes the paper and discusses the Ω(n log n)
time lower bound of the problem 1DkCenter.
For simplicity of discussion, we make a general position assumption that no
two points in P are at the same position on L. We also assume the weight of
each point in P is positive and finite. These assumptions are only for ease of
exposition and our algorithms can be easily extended to the general case.
2.1 Preliminaries
For any two points p and q on L with L(p) ≤ L(q) (recall that L(p) is the
coordinate of p on L, and similarly for L(q)), denote by [p, q] the (closed) interval
of L between p and q.
3
We first sort all points of P from left to right on L. Without loss of generality
(WLOG), let {p1 , p2 , . . . , pn } be the sorted order in increasing coordinates on L.
For any two points pi , pj ∈ P with i ≤ j, denote by I(i, j) the interval [pi , pj ].
Let ψ ∗ be the value of ψ(P, F ) for an optimal solution of 1DkCenter. Suppose F
is the center set in an optimal solution; for a demand point p ∈ P and a center
f ∈ F , if (w(p)·d(f, p)) ≤ ψ ∗ , then we say that p can be served by f . It is easy to
see that there is an optimal solution F such that each center of F is in [p1 , pn ].
Further, as discussed in [2], there is an optimal solution F such that the points
of P are partitioned into k intervals I(1, i1 ), I(i1 + 1, i2 ), . . . , I(ik−1 + 1, n) by
integers i0 + 1 = 1 ≤ i1 ≤ i2 ≤ · · · ≤ ik−1 ≤ n = ik , each interval I(ij−1 + 1, ij )
contains exactly one center fj ∈ F , and for each point p ∈ P ∩ I(ij−1 + 1, ij ),
(w(p) · d(fj , p)) ≤ ψ ∗ holds. In other words, each center of F serves a subset of
consecutive demand points in P .
For any two integers i and j with 1 ≤ i ≤ j ≤ n, denote by Pij the subset of
points of P in the interval I(i, j), i.e., Pij = {pi , pi+1 , . . . , pj } (Pij = {pi } for i =
j). Consider the following weighted 1-center problem: Find a single center (i.e., a
point) f in the interval I[i, j] such that the value of ψ(Pij , f ) = maxpt ∈Pij (w(pt )·
d(pt , f )) is minimized. Let α(i, j) denote the minimum value of ψ(Pij , f ) for this
weighted 1-center problem.
For solving the 1DkCenter problem, our strategy is to determine k−1 integers
1 ≤ i1 ≤ i2 ≤ · · · ≤ ik−1 ≤ n such that the value of max{α(1, i1 ), α(i1 +
1, i2 ), . . . , α(ik−1 + 1, n)} is minimized and this minimized value is ψ ∗ . Note that
in the above formulation, for each value α(i, j), exact one center is determined
in the interval I(i, j). To solve this problem, we reduce it to a planar weighted
point approximation problem [7] in the next subsection.
4
y
error
Fig. 1. Approximating a set of points by a step function (i.e., the three horizontal line
segments).
the demand point set P = {p1 , p2 , . . . , pn } for 1DkCenter with the points or-
dered increasingly by their coordinates on L. For each demand point pi ∈ P ,
1 ≤ i ≤ n, we create a point p′i = (i, L(pi )) in a 2-D Euclidean plane R2 (i.e,
the x-coordinate of p′i in R2 is the index i and its y-coordinate yi′ in R2 is the
coordinate of pi on L), and let the weight of p′i be that of pi (i.e., w(p′i ) = w(pi )).
Let P ′ be the set of n weighted points thus created in R2 . The next lemma states
the relation between 1DkCenter and the reduced instance of WSF.
Proof: For any two integers i and j with 1 ≤ i ≤ j ≤ n, let Pij′ = {p′i , p′i+1 , . . . , p′j }
(Pij′ = {p′i } for i = j). Consider the following problem: Find a value Y for one
single horizontal line segment with Y as its y-coordinate such that the value of
dw (Pij′ , Y ) = maxp′t ∈Pij′ (w(p′t ) · |yt − Y |) is minimized (where yt = L(pt )). Let
α′ (i, j) denote the minimized value of dw (Pij′ , Y ).
Let ǫ∗ be the approximation error of an optimal solution for WSF on P ′ . It
is easy to see that computing an optimal solution for WSF on P ′ is equivalent
to determining k − 1 integers 1 ≤ i1 ≤ i2 ≤ · · · ≤ ik−1 ≤ n such that the
value of max{α′ (1, i1 ), α′ (i1 + 1, i2 ), . . . , α′ (ik−1 + 1, n)} is minimized and this
minimized value is ǫ∗ . According to the way that we create the point set P ′ from
the demand point set P , each value α′ (i, j) is exactly equal to the value α(i, j),
which is the minimized value of ψ(Pij , f ) for the weighted 1-center problem
on the demand point subset Pij by determining the value of f . Further, we
have shown that to find an optimal solution for 1DkCenter on P , it suffices to
determine k − 1 integers 1 ≤ i1 ≤ i2 ≤ · · · ≤ ik−1 ≤ n such that the value of
max{α(1, i1 ), α(i1 + 1, i2 ), . . . , α(ik−1 + 1, n)} is minimized and the minimized
value is ψ ∗ .
The above discussion shows that to find an optimal solution for 1DkCenter
on P , it suffices to find an optimal solution for WSF on P ′ ; further, ψ ∗ = ǫ∗ .
Given an optimal solution OPT P ′ for WSF on P ′ , below we show how to obtain
an optimal solution OPT P for 1DkCenter on P from OP TP ′ in linear time.
Note that OPT P ′ is a step function with k steps (i.e., horizontal line seg-
ments). Let i0 = 0 and ik = n. For each 1 ≤ j ≤ k, suppose the j-th step of
OPT P ′ has a y-coordinate y j and covers the points of P ′ from p′ij−1 +1 to p′ij ,
i.e., for each point p′t ∈ P ′ with ij−1 + 1 ≤ t ≤ ij , the vertical line through p′t
5
intersects the j-th horizontal segment of OPT P ′ . We obtain OPT P for 1DkCenter
on P as follows. For each 1 ≤ j ≤ k, the j-th center fj is put at the position y j
on L (i.e., L(fj ) = y j ), which serves the demand points of P from pij−1 +1 to pij .
Thus, once OPT P ′ is available, OPT P can be obtained in O(n) time. ✷
Based on Lemma 1, to compute a set F of k centers for P to minimize the
value ψ(P, F ), it suffices to solve the corresponding WSF problem on P ′ and k.
Specifically, after an optimal step function g for P ′ is obtained, each horizontal
segment of g defines a center on L whose coordinate is equal to the y-coordinate
of that horizontal segment of g in R2 .
To apply the WSF algorithms to the 1DkCenter problem, we need a data
structure for answering queries q(i, j) = α(i, j) with 1 ≤ i ≤ j ≤ n. Suppose
such a data structure can be built in O(π(n)) time and can answer each query
α(i, j) in O(q(n)) time; then we say the time bounds of the data structure are
O(π(n), q(n)). The two lemmas below follow from the results in [7].
Lemma 2. [7] Suppose there is a data structure for the queries α(i, j) with time
bounds O(π(n), q(n)); then the 1DkCenter problem is solvable in O(π(n)+n·q(n))
time.
Lemma 3. [7] Suppose there is a data structure for the queries α(i, j) with time
bounds O(π(n), q(n)); then the 1DkCenter problem is solvable in O(π(n) + q(n) ·
k 2 log2 nk ) time.
Refer to [7] for the details of the algorithms in the above two lemmas. By
the above two lemmas, Lemma 4 follows.
Lemma 4. Suppose there is a data structure for the queries α(i, j) with time
bounds O(π(n), q(n)); then the 1DkCenter problem can be solved in O(min{π(n)+
n · q(n), π(n) + q(n) · k 2 log2 nk }) time.
A data structure based on fractional cascading [5] was given in [7] for an-
swering the queries α(i, j) with time bounds O(n log n, log2 n). Consequently,
by Lemma 4, the 1DkCenter problem is solvable in O(min{n log2 n, n log n +
k 2 log2 nk log2 n}) time. In Section 3, we develop a data structure for processing
the queries α(i, j) with time bounds O(n log n, log n), which allows us to solve
1DkCenter in O(n log n) time.
The reason why we can solve the 1DkCenter problem faster than simply
applying the WSF algorithms [7] is that the WSF instance constructed above
from the problem 1DkCenter has a special property: The y-coordinates of the
points p′1 , p′2 , . . . , p′n are increasing. As shown in Section 3, this special property
allows us to design a new data structure for the α(i, j) queries with time bounds
O(n log n, log n). Note that this special property does not hold for the general
WSF problem studied in [7].
6
p*=(x*,y*)
p1 x* p2 p3
Fig. 2. Illustrating the common intersection of the half-planes defined by three points
p1 , p2 , and p3 . The point p∗ is the lowest point in the common intersection.
7
Yet, the 2-D sublist LP query problem for 1DkCenter is special in the follow-
ing sense. For each half-plane h ∈ HP for 1DkCenter, we call the x-coordinate
of the intersection point between L (i.e., the x-axis) and the line bounding h the
x-intercept of h (or its bounding line). As discussed above, for each point pt ∈ P ,
the x-intercepts of both the half-planes h2t−1 and h2t defined by pt are exactly
the point pt . Since all points of P are ordered along L from left to right by their
indices, a special property of HP is that the x-intercepts of all half-planes in HP
are ordered from left to right on L by the indices of the half-planes. For a set H
of half-planes for a 2-D sublist LP query problem instance, if H has the above
special property, then we say that H is x-intercept ordered.
Below, we show that if H is x-intercept ordered, then there is a data structure
for the specific 2-D sublist LP query problem with time bounds O(n log n, log n).
Henceforth, we assume that H is an x-intercept ordered half-plane set. In the
1DkCenter problem, since all the point weights for P are positive finite values,
the bounding line of each half-plane in HP is neither horizontal nor vertical.
Thus, we also assume that no bounding line of any half-plane in H is horizontal
or vertical. Again, this assumption is only for simplicity of discussion.
In the next section, we solve the 2-D sublist LP queries by reducing it to
computing the convex hull of a query sub-path of a given simple path [16]. Given
a simple path in the plane, based on compact interval trees, data structures are
proposed in [16] to compute (in logarithmic time) the convex hull of a query
subpath that is specified by the indices of the beginning vertex and the end
vertex of the subpath, and the convex hull is represented (by a compact interval
tree) such that standard convex hull queries on it can be done in O(log n) time.
For each half-plane hi ∈ H, we denote by l(hi ) the bounding line of hi ; let l(H ′ )
be the set of the bounding lines of the half-planes in any subset H ′ ⊆ H.
Our problem reduction utilizes a duality transformation [11], which is a tech-
nique commonly used in computational geometry, as follows. Suppose we have a
primary plane P. For each point (a, b) ∈ P, it corresponds to a line y = ax − b
in the dual plane D; the line is also called the dual of the point and vice versa.
Similarly, each line y = a′ x − b′ in P corresponds to a point (a′ , b′ ) in D.
Suppose all half-planes in H are in the primary plane P. By duality, we can
obtain a set H ∗ of points in the dual plane D corresponding to the lines in l(H).
For each query q(i, j) on H, our goal is to locate the lowest point p∗ in the
common intersection of all half-planes in Hij (note that due to our assumption
that no line in l(H) is horizontal, there is only one lowest point in the common
intersection). Since all half-planes in H are upper half-planes, an observation
is that p∗ is also the lowest point of the upper envelope of the arrangement of
the lines in l(Hij ). Denote by Uij the above upper envelope for l(Hij ). Denote
∗
by Hij the set of points (in the dual plane D) dual to the lines in l(Hij ). Let
∗ ∗
Cij denote the lower hull of the convex hull of Hij . It is commonly known [11]
∗
that the dual of Uij is exactly Cij (in the dual plane D). Therefore, if we have
8
∗
a representation of Cij that can support standard binary-search-based queries,
then we can compute the lowest point p∗ in logarithmic time accordingly.
One may attempt to design a data structure for querying the lower hull on
∗
any subset Hij of H ∗ . However, there are difficulties when doing so “directly”,
which will be explained later. Instead, we use an “indirect” approach, as follows.
Recall that we have assumed the bounding line of any half-plane in H is not
vertical or horizontal. We partition the half-plane set H into two subsets H1
and H2 such that a half-plane hi of H is in H1 (resp., H2 ) if and only if the
slope of l(hi ) is negative (resp., positive). Accordingly, for each subset Hij , we
1 2
also have Hij and Hij , and we define the envelopes Uij1 and Uij2 accordingly.
1
Since the bounding lines of all half-planes in Hij have negative slopes, the upper
1
envelope Uij is monotone decreasing from left to right. Similarly, the upper
envelope Uij2 is monotone increasing from left to right. Hence, it is easy to see
that the lowest point p∗ is the single intersection of Uij1 and Uij2 . Let Hij ∗1
and
∗2 1
Hij be the sets of points in the dual plane corresponding to the lines in l(Hij )
2 ∗1 ∗2 ∗1 ∗2
and l(Hij ), respectively. Denote by Cij and Cij the lower hulls of Hij and Hij ,
respectively. By duality, the intersection of Uij1 and Uij2 corresponds exactly to
∗1 ∗2
the common tangent line of the two lower hulls Cij and Cij such that both hulls
1
are above the tangent line. Note that since all lines in Hij have negative slopes,
∗1
by duality, all points in Hij are to the left of the y-axis in the dual plane, and
∗1 ∗2
thus the lower hull Cij is to the left of the y-axis. Similarly, the lower hull Cij
∗1 ∗2
is to the right of the y-axis. Namely, the two lower hulls Cij and Cij are on
different sides of the y-axis. This property can make our computation of their
tangent line easier.
∗1 ∗2
In summary, if we can represent both Cij and Cij in such a way that the
∗
common tangent line can be found efficiently, then p can be obtained immedi-
ately. Our remaining task is to derive a way to support convex hull (or lower
hull) queries on any subset of consecutive points in H1∗ (and similarly on H2∗ ).
Our result is that a data structure can be built in O(n log n) time such that given
∗1
any i ≤ j, the lower hull Cij can be obtained (implicitly) in O(log n) time and
is represented in a way that supports binary-search-based queries (e.g., compute
∗2
the common tangent of it and another lower hull, say Cij ). The details are given
below.
Without loss of generality, we assume the bounding lines of the half-planes
in H all have negative slopes (i.e., H = H1 ) and the other case can be handled
analogously. Suppose the bounding line of each hi ∈ H corresponds to the point
h∗i ∈ H ∗ in the dual plane D. Let γ be the path by connecting all pairs of
two consecutive points in H ∗ by line segments, i.e., connecting h∗i to h∗i+1 for
i = 1, 2, . . . , n − 1. Consider the line segment connecting h∗i and h∗i+1 and the
line segment connecting h∗j and h∗j+1 ; then the two segments are adjacent to each
other if i + 1 = j or j + 1 = i. The following Lemma 5 shows that the path γ is
a simple path, that is, any two line segments of γ that are not adjacent do not
intersect. As can be seen from the proof of Lemma 5, we note that the correctness
of Lemma 5 heavily relies on two properties of H: (1) H is x-intercept ordered;
9
xi xj
x
hj+1
hi
hi+1 hj
Fig. 3. Illustrating the two double edges dw(si ) and dw(sj ) (the shaded regions) in
the primary plane P corresponding to the two segments si and sj in the dual plane D.
The two segments xi and xj are their intersections with the x-axis.
(2) the slopes of the bounding lines of the half-planes in H are all negative (or
positive). Without either property above, the lemma would not hold, and the
second property also explains why we need to partition the original set H into
H1 and H2 .
Lemma 5. The path γ is a simple path.
Proof: Consider two segments si and sj where si connects h∗i and h∗i+1 and sj
connects h∗j and h∗j+1 . Suppose si and sj are not adjacent. To prove the lemma, it
is sufficient to show si and sj does not intersect. Since si and sj are not adjacent,
either i + 1 < j or j + 1 < i. Without loss of generality, assume i + 1 < j.
Note that si and sj are in the dual plane D. It is commonly known [11] that
the dual of si in the primary plane P is the double wedge bounded by the lines
l(hi ) and l(hi+1 ) such that the double wedge does not contain a vertical line
(e.g., see Fig. 3); we denote the double wedge by dw(si ). Similarly, the dual of
sj is the double wedge dw(sj ) bounded by l(hj ) and l(hj+1 ).
Assume to the contrary the two segments si and sj intersect each other, say,
at a point p. Then, p corresponds to a line in the primary plane P, which is in the
common intersection of the two double wedges dw(si ) and dw(sj ). However, we
claim that the common intersection of dw(si ) and dw(sj ) does not contain any
line, which incurs contradiction. Hence, si cannot intersect sj and the lemma
follows. Below, we prove the above claim.
Suppose to the contrary there is a line l contained in dw(si ) ∩ dw(sj ). Denote
by xi (resp., xj ) the intersection of the x-axis and dw(si ) (resp., dw(sj )), e.g.,
see Fig. 3. Hence, both xi and xj are line segments on the x-axis. Since the
intersection of l(hj ) and the x-axis is strictly to the right of the intersection of
l(hi+1 ) and the x-axis (since H is x-intercept ordered), xi does not intersect xj .
Since the slopes of both l(hi ) and l(hi+1 ) are negative, a line contained in dw(si )
must intersect xi , and thus the line l intersects xi (due to l ⊆ dw(si ) ∩ dw(sj )).
Similarly, l also intersects xj . Hence, we obtain that l intersects both xi and xj .
Since both xi and xj lie in x-axis and xi does not intersect xj , the line l has to
be the x-axis. However, since the slopes of both l(hi ) and l(hi+1 ) are negative,
the double wedge dw(si ) cannot contain the x-axis and thus cannot contain l.
Therefore, we obtain contradiction and the claim follows. ✷
10
In light of Lemma 5, we can utilize the results in [16]. Given a simple path in
the plane, compact interval tree data structures are proposed in [16] to compute
the convex hull of a query subpath that is specified by the indices of the beginning
vertex and the end vertex of the subpath. If applied to γ in our problem, then
after spending O(n log n) time sorting the points in H ∗ by their x-coordinates, we
have the following results: A data structure can be constructed in O(n log log n)
∗
time that can compute the lower hull Cij for any query q(i, j) in O(log n) time
∗
and Cij is represented (by a compact interval tree) such that any standard
∗
convex hull queries on Cij can be done in O(log n) time, where the standard
convex hull queries includes point-in-polygon tests, finding intersections with
lines, finding tangents through query points, finding extreme vertices in a query
direction, detecting intersections of two polygons, and finding common tangents
of two convex hulls. Further, another data structure of construction time O(n)
and query time O(log n log log n) is also given in [16]; in addition, there is also a
data structure of construction time O(n log∗ n) and query time O(log n log∗ n) by
making trade-off between the construction and query [16]. Both data structures
are applicable to our problem.
By duality, the x-coordinate of each point h∗i ∈ H ∗ corresponds to the slope
of the line l(hi ). Thus, a sorted order of the points in H ∗ by x-coordinate corre-
sponds to a sorted order of the bounding lines of the half-planes in H by slope.
The following lemma summarizes our discussions above.
Lemma 6. In O(n log n) time, we can build a data structure that can answer
each 2-D sublist LP query in O(log n) time. Further, if the bounding lines of
the half-planes in H are sorted by their slopes, then there exist three data struc-
tures for the 2-D sublist LP queries, whose construction time complexities are
O(n), O(n log∗ n), and O(n log log n), respectively, and query time complexities
are O(log n log log n), O(log n log∗ n), and O(log n), respectively.
Corollary 1. There exists a data structure of time complexity O(n log n, log n)
for the α(i, j) queries. Further, if the points of P are sorted on the line L and the
weights of the points in P are also sorted, then we have three data structures for
the α(i, j) queries of time complexities O(n, log n log log n), O(n log∗ n, log n log∗ n),
and O(n log log n, log n), respectively.
11
Therefore, if the points of P are sorted on the line L and the weights of the
n
points in P are also sorted, for small k (e.g., k = O(( log3 n log log n
)1/2 ), which is
true in many applications), the 1DkCenter problem is solvable in O(n) time.
4 Conclusions
In this paper, we give an O(n log n) time algorithm for the k-center problem on
a real line. In certain special cases, we can solve the problem in linear time. We
also propose an efficient data structure to answer the 2-D sublist LP queries,
which may find other applications.
As suggested by Tamir, when k = n − 1, the discrete unweighted 1DkCenter
is equivalent to the Min Gap problem, i.e., finding the closest pair of neighbors
in P . Hence, there is an O(n log n) time lower bound on the discrete version. In
fact, by the reduction from the Min Gap problem, we can also show that the
non-discrete unweighted 1DkCenter also has an O(n log n) lower bound on the
running time. Indeed, in any optimal solution OP T for k = n − 1, there must
be a center at the middle position of the closest pair of neighbors in P , and that
center serves both neighbors; further, any other center in OP T serves one and
only one demand point in P . Therefore, given an optimal solution OP T , since
the demand points served by each center are known, the two demand points
served by the same center are the closest neighbors in P . We thus obtain the
O(n log n) time lower bound on the non-discrete unweighted 1DkCenter.
Note that the linear time algorithms for the unweighted continuous/discrete
k-center problem on trees [14] do not violate the O(n log n) time lower bound
discussed above because the tree structure already gives a partial order of the
nodes in the tree. An open problem is whether the techniques given in this paper
can be extended to the tree structure.
Acknowledgments
We wish to thank Arie Tamir for his many helpful comments and suggestions.
References
12
5. B. Chazelle and L. Guibas. Fractional cascading: I. A data structuring technique.
Algorithmica, 1(1):133–162, 1986.
6. D.Z. Chen and H.Wang. A note on searching line arrangements and applications.
Information Processing Letters, 113:518–521, 2013.
7. D.Z. Chen and H. Wang. Approximating points by a piecewise linear function:
I. In Proc. of the 20th International Symposium on Algorithms and Computa-
tion (ISAAC), volume 5878 of Lecture Notes in Computer Science, pages 224–233.
Springer, 2009.
8. D.Z. Chen and H. Wang. Efficient algorithms for the weighted k-center problem
on a real line. In Proc. of the 22nd International Symposium on Algorithms and
Computation (ISAAC), pages 584–593, 2011.
9. D.Z. Chen and H. Wang. Approximating points by a piecewise linear function.
Algorithmica, 88:682–713, 2013.
10. R. Cole. Slowing down sorting networks to obtain faster sorting algorithms. Journal
of the ACM, 34(1):200–208, 1987.
11. M. de Berg, O. Cheong, M. van Kreveld, and M. Overmars. Computational Geom-
etry — Algorithms and Applications. Springer-Verlag, Berlin, 3rd edition, 2008.
12. M. Dyer. Linear time algorithms for two- and three-variable linear programs. SIAM
J. Comp., 13(1):31–45, 1984.
13. H. Fournier and A. Vigneron. A deterministic algorithm for fitting a step function
to a weighted point-set. Information Processing Letters, 113:51–54, 2013.
14. G.N. Frederickson. Parametric search and locating supply centers in trees. In Proc.
of the 2nd International Workshop on Algorithms and Data Structures (WADS),
pages 299–319, 1991.
15. G.N. Frederickson and D.B. Johnson. Finding kth paths and p-centers by gen-
erating and searching good data structures. Journal of Algorithms, 4(1):61–80,
1983.
16. L. Guibas, J. Hershberger, and J. Snoeyink. Compact interval trees: A data struc-
ture for convex hulls. International Journal of Computational Geometry and Ap-
plications, 1(1):1–22, 1991.
17. M. Jeger and O. Kariv. Algorithms for finding P -centers on a weighted tree (for
relatively small P ). Networks, 15(3):381–389, 1985.
18. O. Kariv and S.L. Hakimi. An algorithmic approach to network location problems.
I: The p-centers. SIAM J. on Applied Mathematics, 37(3):513–538, 1979.
19. M. Katz and M. Sharir. Optimal slope selection via expanders. Information Pro-
cessing Letters, 47(3):115–122, 1993.
20. J.-Y. Liu. A randomized algorithm for weighted approximation of points by a step
function. In Proc. of the 4th International Conference on Combinatorial Optimiza-
tion and Applications, pages 300–308, 2010.
21. N. Megiddo. Linear programming in linear time when the dimension is fixed.
Journal of the ACM, 31(1):114–127, 1984.
22. N. Megiddo and A. Tamir. New results on the complexity of p-centre problems.
SIAM J. on Computing, 12(4):751–758, 1983.
23. N. Megiddo, A. Tamir, E. Zemel, and R. Chandrasekaran. An O(n log2 n) algorithm
for the k-th longest path in a tree with applications to location problems. SIAM
J. on Computing, 10:328–337, 1981.
24. A. Tamir. Personal communication, 2014.
13