Is there any known algorithm to solve this ?
Asked
Active
Viewed 157 times
0
-
Of course there is some kind of an algorithm you could use. What kind of time complexity are you trying to achieve? – ollpu Nov 01 '16 at 16:53
-
3This is asking for an algorithm, not help with broken code – thecoshman Nov 01 '16 at 17:05
-
Are the centers also integers, or could they be halves? – m69's been on strike for years Nov 01 '16 at 19:14
1 Answers
1
There's a related problem that's solvable with a greedy algorithm: given the points and a radius, find the minimum number of circles. This algorithm repeatedly places a circle whose left edge lies on the leftmost uncovered point, running in time O(n) on points sorted by x.
To get an algorithm for the requested problem, sort the points once and then use binary search to find the least radius that will result in at most d circles. Assuming that the x coordinates can be represented by machine words, this should be fine. (If not, there are other algorithms.)

David Eisenstat
- 64,237
- 7
- 60
- 120
-
@Blender He is suggesting you to use binary search on answer and I agree with him. Similar to this questions: [link](http://stackoverflow.com/questions/40189551/arrange-n-items-in-k-nonempty-groups-such-that-the-difference-between-the-minimu/40205972#40205972) and [link](http://stackoverflow.com/questions/39673898/divide-array-into-k-contiguos-partitions-such-that-sum-of-maximum-partition-is-m/39675098#39675098) – Saeid Nov 02 '16 at 00:24