A RANDOMIZED ALGORITHM FOR WEIGHTED APPROXIMATION OF POINTS BY A STEP FUNCTION
Jinyi Liu · Discrete Mathematics Algorithms and Applications · 2011
The problem considered in this paper is: Given an integer k > 0 and a set P of n points in the plane each with a corresponding nonnegative weight, find a step function f with k steps that minimize the maximum weighted vertical distance between f and all the points in P. We present a randomized algorithm to solve the problem in O(n log n) expected running time. The bound is obviously optimal for the unsorted input. The previously best known algorithm runs in O(n log 2 n) worst-case time. Another merit of the algorithm is its simplicity. The algorithm is just a randomized implementation of Frederickson and Johnson's matrix searching technique, and it only exploits a simple data structure.