开发者

Grid Algorithms

开发者 https://www.devze.com 2023-02-06 01:01 出处:网络
This being my first post on stackoverflow, so pardon me if i am asking a question which has already been answered. Can someone direct me to a good tutoria开发者_如何学Gol to help me solve grid problem

This being my first post on stackoverflow, so pardon me if i am asking a question which has already been answered. Can someone direct me to a good tutoria开发者_如何学Gol to help me solve grid problems where we are to do that problem in 'minimum' number of steps possible. Sometimes BFS does help but is not sufficient for other similar problems. Thanks :)


Without more info, it's hard to give a good answer. Good algorithms depend on the exact statement of the problem.

If the entire grid is defined, and all edges exist and have the same weight, the minimum is easily defined as walking the "diagonal" between two points. No clever algorithm is needed.

If some edges exists, or edges have variable weights which are positive, I would suggest Dijkstra's algorithm. If some edges are negative, there are variants such as Bellman-Ford.

Anyway, you need to elaborate on the setup so we can help you.


If you want to reduce the complexity and the order of the grid you can use space-filling-curve for example a z-curve, hilbert curve or peano curve.

0

精彩评论

暂无评论...
验证码 换一张
取 消