Given a circle with N defined points and a point M outside the circle, find the point closest to M from the set N. O (LogN)

http://www.glassdoor.com/Interview/Google-Interview-RVW2382108.htm

I tried to come to a solution to this problem. But I did not succeed. Can someone give me a hint on how to continue this issue.

I will take 2 pairs of two points each. That is, I will make 2 chords. Find out their perpendicular bisector. Using these bisectors, I recognize the center of the circle ...

In addition, I will come up with a circle equation. And find the intersection point of point M with the circle ... It should be the nearest point. However, this point may or may not exist in the set of N points

Thank.

+5
source share
2 answers

, "" (.. ), , O(log(n)).

  • A M - O(1).
  • , I A - O(log(n)).
  • , M I, I+1. - O(1).
+5

, M, . , , M O (lgn) .

  • ( ) (r, θ), r - , θ - x (-180,180).
  • N x.

, , M, , ,

  • , θ = (-130, -100, -90, -23, -15,0,2,14,170), M θ = -170 -130 (40 ) , 170 (20 ) - M.
  • (, ), θ = (0,2,14,15,23,90,100,130,170), M θ = -6 2, 14, 0 M .

,

  • , , M.
  • [90 + θ, -90 + θ) [-90 + θ, 90 + θ) , M .
  • , , , , .
  • , . M. O (lgn).

planar elimination

, , ( ) , .

+1

All Articles