我只是想实现最佳优先搜索,我不确定该算法是否有任何 LIFO 或 FIFO 属性。如果是这样,我应该使用哪一个?我需要使用它吗?
最佳答案
参见 http://en.wikipedia.org/wiki/Best-first_search#Algorithm_.5B3.5D对于这个伪代码:
OPEN = [initial state]
while OPEN is not empty or until a goal is found
do
1. Remove the best node from OPEN, call it n.
2. If n is the goal state, backtrace path to n (through recorded parents) and return path.
3. Create n's successors.
4. Evaluate each successor, add it to OPEN, and record its parent.
done
第 1 步说“删除最佳节点”- 这意味着使用 Priority Queue .
关于java - Greedy Best First Search 使用队列还是堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13424488/