How to compute the running time of A-star algorithm

[亡魂溺海] 提交于 2019-12-11 06:37:35

问题


I am working with A* algorithm. I have a 2D grid, with some obstacles, and given the starting and final position, I find the shortest path between them.

Here's my pseudocode

while(queueNotEmpty){
  removeFromPQ;
  if(removed == destination)
    found;
  insertAllNeighbours;
}

Remove and insert are the function on priority queue(Heap), and is O(log(n)) time.

Considering the dimension of grid as N*N. How do I calculate the running time. i.e how many times will this loop execute? Is there any measure?


回答1:


Runtime of standard A* is exponential in the length of the solution (worst-case).

If you're searching on a grid of n*n, and you use graph-search, the search will visit each node at most once; so it's O(n*n). But the found solution will only be optimal if the used heuristic is monotone (in addition to being admissible).

There are also conditions for polynomial runtime of standard A*.

For Graph-Search vs. Tree-Search see this answer.



来源:https://stackoverflow.com/questions/16141678/how-to-compute-the-running-time-of-a-star-algorithm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!