gpt4 book ai didi

java - Greedy Best First Search 使用队列还是堆栈?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:34:58 24 4
gpt4 key购买 nike

我只是想实现最佳优先搜索,我不确定该算法是否有任何 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com