Greedy Best First Search是否使用队列或堆栈?

Joh*_* Au 1 java algorithm queue stack greedy

我只是尝试实现最好的第一次搜索,我不确定该算法是否有任何LIFO或FIFO属性.如果是的话我应该使用哪一个?我需要使用它吗?

Dyl*_*lan 5

有关此伪代码,请参见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
Run Code Online (Sandbox Code Playgroud)

步骤1说"删除最佳节点" - 这意味着使用优先级队列.

  • 不,优先级队列的关键特征是无论插入顺序如何,"最佳"(由比较器确定)元素始终位于前面.查看http://docs.oracle.com/javase/1.5.0/docs/api/java/util/PriorityQueue.html - (4认同)