9

I'm looking for an algorithm or data structure to solve the following problem: You are given a set of points S. And you are given Q queries in form of another point. For every query, find the farthest point in the set from the given point.

There are at most 10^5 points in the set and 10^5 queries. All the coordinates for points are in range from 0 to 10^5.

I am wondering if there is a way to store the set of points such that we can answer the queries in O(log n) or O(log^2 n) if necessary.

Nikola Pesic
  • 101
  • 1
  • 5
  • If I was asked to implement it, I would personally try to find the center of the plane ([average X of all points, average Y of all points]) and try to divide the plane into N radial sections with known maximum distance (diameter), so that you at least know where to start to search for an answer and what to expect. It can give some improvement, but still within `O(n*n)` asymptotic time, so I won't post it as an answer. There may be some sort of faster algorithm, something with divide & conquer or finding the outer points of a convex polygon. Interesting question indeed! :) – Yeldar Kurmangaliyev Jan 11 '19 at 20:44
  • 2
    Does this help? https://codeforces.com/blog/entry/50466 – גלעד ברקן Jan 11 '19 at 22:01
  • Euclidean plane? – David Eisenstat Jan 11 '19 at 22:57
  • Also, are the queries online or offline? – David Eisenstat Jan 12 '19 at 00:01
  • @גלעדברקן The ternary search answer doesn't work. Furthest point Voronoi is a reasonable answer, but I'm wondering how to build and do point location in the diagram without writing a ton of code. – David Eisenstat Jan 12 '19 at 00:03
  • @DavidEisenstat well, geez, if you can't make an answer happen, who can?:) I've yet to study about farthest point Voronoi. My question about whether the link might be helpful was genuine. – גלעד ברקן Jan 12 '19 at 00:14
  • I got my anwer for online(the anwer below) and offline(https://codeforces.com/blog/entry/50466?#comment-343629) queries. The guy in the comment says that he has no proof, but the comment has upvotes, so, if someone can tell me if the algorithm he proposed is correct/incorrect that would be wonderfull. Thank you all! – Nikola Pesic Jan 12 '19 at 11:25
  • @NikolaPesic Haven't worked out a counterexample in detail, but I'm quite sure that idea doesn't work. – David Eisenstat Jan 12 '19 at 12:47

1 Answers1

1

A quote from "Approximate Furthest Neighbor with Application to Annulus Query":

In two dimensions the furthest neighbor problem can be solved in linear space and logarithmic query time using point location in a furthest point Voronoi diagram (see, for example, de Berg et al. [5]).

where [5] refers to the "Marks textbook":

Berg, Mark de, Otfried Cheong, Marc van Kreveld, and Mark Overmars. Computational geometry: algorithms and applications. Springer-Verlag TELOS, 2008.


          Fig
          Farthest-Neighbor Voronoi diagram for a set of eight points.
Image from Jacometti, Welson. "A Note on Primitives for the Manipulation of General Subdivisions and the Computation of Voronoi Diagrams." (1992).

Joseph O'Rourke
  • 4,346
  • 16
  • 25