K Centers Problem Set 1 (Greedy Approximate Algorithm) : Triangular Inequality
K Centers Problem Set 1 (Greedy Approximate Algorithm) : Triangular Inequality
KCentersProblem|Set1(GreedyApproximateAlgorithm)
Given n cities and distances between every pair of cities, select k cities to place warehouses (or ATMs or
Cloud Server) such that the maximum distance of a city to a warehouse (or ATM or Cloud Server) is
minimized.
For example consider the following four cities, 0, 1, 2 and 3 and distances between them, how do place
2 ATMs among these 4 cities so that the maximum distance of a city to an ATM is minimized.
There is no polynomial time solution available for this problem as the problem is a known NP-Hard
problem. There is a polynomial time Greedy approximate algorithm, the greedy algorithm provides a
solution which is never worse that twice the optimal solution. The greedy solution works only if the
distances between cities follow Triangular Inequality (Distance between two points is always smaller
than sum of distances through a third point).
http://www.geeksforgeeks.org/kcentersproblemset1greedyapproximatealgorithm/ 1/2
5/23/2017 KCentersProblem|Set1(GreedyApproximateAlgorithm)GeeksforGeeks
c) Remaining cities are 2 and 3. Calculate their distances from already selected centers (0 and 1). The
greedy algorithm basically calculates following values.
After computing the above values, the city 2 is picked as the value corresponding to 2 is maximum.
Note that the greedy algorithm doesnt give best solution for k = 2 as this is just an approximate
algorithm with bound as twice of optimal.
a) Assume that the distance from the furthest point to all centers is > 2OPT.
b) This means that distances between all centers are also > 2OPT.
d) Each point has a center of the optimal solution with distance <= OPT to it.
e) There exists a pair of points with the same center X in the optimal solution (pigeonhole principle: k
optimal centers, k+1 points)
f) The distance between them is at most 2OPT (triangle inequality) which is a contradiction.
Source:
http://algo2.iti.kit.edu/vanstee/courses/kcenter.pdf
This article is contributed byHarshit. Please write comments if you nd anything incorrect, or you want
to share more information about the topic discussed above
http://www.geeksforgeeks.org/kcentersproblemset1greedyapproximatealgorithm/ 2/2