Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
Is there any known algorithm to solve this ?
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.)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am creating a program to solve this puzzle in the lowest cost
The sliding-title puzzle consists of three black titles, three white titles, and an empty space in the configuration shown in the Figure.
WWW_BBB
The goal of the puzzle is to get all white tiles to the right of the
black tiles while the location of the space does not matter
The puzzle has two legal moves(i.e. actions) with associated costs:
• A title may move into an adjacent empty location. – This has a step cost of
• A title can hop over one or two other tiles into the empty position.
– This has a step cost equal to the number of tiles jumped over.
I am having troubles understand how to create a Heuristic algorithm to be implemented in the algorithm.
I understand the implementation of Dijkstra's algorithm within this problem, but can't figure out how to then make it into the A* algorithm.
Assuming you want to use A* on the graph of puzzle states with edges to the states reachable through one of the two rules, then a good heuristic to use would be the number of inversions: https://en.wikipedia.org/wiki/Inversion_(discrete_mathematics)
That's the number of W,B pairs that are out of order (assuming that the relative order of same-colored tiles doesn't change). The W's and B's are in order when the number of versions is 0, and the number of inversions fixed by each type of move is less than or equal to its cost. Therefore the number of inversions as a heuristic will never overestimate the cost of the best sequence.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I need to find the minimum number of pinsneeded to place on an N-by-M rectangular grid (N horizontal line segments and M vertical line segments) to enclose at least K intersection points. An intersection point is enclosed if either of the following conditions is true:
A pin is placed at the point.
Starting from the point, we cannot trace a path along grid lines to reach an empty point on the grid border through empty intersection points only.
For example, to enclose 8 points on a 4x5 grid, we need at least 6 pins. One of many valid pin layouts is
Enclosed points are marked with an "x".
I've thought over the problem but I cant seem to find a solution. Could any of you please help?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
A math problem I've been stuck on for a couple days.
Given a set of points on a 2D plane (more than 11), find the largest circle possible which will not enclose more than 11 points.
The obvious approach would be to take all possible subsets of size 12, then find the minimum enclosing circle for each, but that would take far too long to calculate.
any ideas on a more efficient method?
I suspect that there's a thoroughly impractical O(n log n)-time algorithm that computes the order-12 (!) Voronoi diagram and proceeds as in the O(n log n)-time algorithm for largest empty circle. Realistically, every viable circle is determined by three of the input points (on the boundary) or two (as the diameter). Naively trying all of them is quartic time, but for each pair of points P and Q, the points on one side of the line PQ are totally ordered with respect to which other points above the circle encloses, as are the points below. This insight gets us to n^3 log n, by sorting; quadratic should be possible using a selection algorithm.
For each point:
Compute the distance to every other point - O(n)
Run a selection algorithm to find the 12th closest point - O(n).
Let x = the distance between these two points.
Find the minimum x. Subtract the smallest possible value from that value, then you have your circle diameter.
Running time: O(n2).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
The problem is to find the point minimizing the travel distance for around 100 persons in different regions who want to meet in the same place. Travel is by car not by plane.
Assuming that I get access to an API giving me mileage / kilometric distance in terms of highway travel between any two points, how can I find the best place to meet?
On other Stackexchange sites (gis.stackexchange.com/questions/65563/meeting-point-minimizing-travel-distance-for-participants) I got directed to the Weiszfeld algo to solve this problem of geometric median.
I suspect that kilometric distance complexifies the problem, because it becomes possible to get stuck in local minima. I don't know really where to start. Any pointer would be appreciated.
Even though it may suffer from local minima, I would try local search, since road networks aren't adversarially designed. Pick a random starting point and then iterate as follows. Compute directions from the current point to the 100 clients. Evaluate each of the next-to-last stops in the directions and move the point to the best.
If the distances taken into account are Manhattan distances then the optimal meeting point is one of the points which has a x-coordinate equal to the x-coordinate of some input point, and the y-coordinate equal to the y-coordinate of some input point.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was curious if there was an elegant way to do this, aside from just calculating the distance from the point to each side and finding the minimum.
Some things I've thought about:
If it's a square, we can just draw the diagonals and figure out which of the 4 regions the point falls on. Each of these region corresponds to a closest side.
Perhaps we can divide up the rectangle into squares and go somewhere from there?
It seems an alternative solution would be too complicated and not worth looking for.
For rectangle you can use following regions:
I think the rectangle is not orthogonal to the coordinate system. First calculate the middle point of every side. This should be simple depending on how you have define the rectangle.
Then calculate the distance to this middle points. The smallest distance is the nearest side. You need not to calculate the full distance with pytagoras. The sum of the squared is enough.