Algorithm 展开节点意味着什么?
我试图理解wikipedia上深度有限搜索的算法,并试图弄清楚扩展节点的确切含义。我试图寻找答案,但我得到的只是更多的算法,这些算法规定节点必须扩展 具体来说,Algorithm 展开节点意味着什么?,algorithm,nodes,depth-first-search,Algorithm,Nodes,Depth First Search,我试图理解wikipedia上深度有限搜索的算法,并试图弄清楚扩展节点的确切含义。我试图寻找答案,但我得到的只是更多的算法,这些算法规定节点必须扩展 具体来说,stack:=expand(node)这一行对整个函数说了什么 DLS(node, goal, depth) { if (node == goal) return node; push_stack(node); while (stack is not empty)
stack:=expand(node)
这一行对整个函数说了什么
DLS(node, goal, depth)
{
if (node == goal)
return node;
push_stack(node);
while (stack is not empty)
{
if (depth > 0)
{
stack := expand (node)
node = stack.pop();
DLS(node, goal, depth-1);
}
else
// no operation
}
}
在此上下文中,它将节点的所有子节点作为新堆栈返回。这是一段写得非常糟糕的示例代码。扩展节点”意味着发现节点的子节点。你认为你能给我指出一个更好的例子吗?在维基百科之外,我似乎找不到太多关于深度限制搜索的内容。这听起来像是一个简单的深度优先搜索,跟踪深度,一旦达到某个限制就停止递归。将现有的基于递归的深度优先搜索修改为相同的方式应该是相当简单的。