【问题标题】:java iterative deepening on tree without recursionjava在没有递归的情况下在树上迭代加深
【发布时间】:2014-03-28 10:35:18
【问题描述】:

我目前的深度优先搜索实现如下:

protected void algorithmLogic() {
    currentNode = ((Stack<Node>) expanded).pop();
    if(atGoal()) {
        // Goal reached so stop
        return;
    }
    else {
        visited.add(currentNode);
        if(currentNode.hasChild()) {
            for(int i=currentNode.getChildren().size()-1;i>-1;i--) {
                ((Stack<Node>) expanded).push(currentNode.getChildren().get(i));
            }
        }
    }
}

这是在节点上的树上工作。

是否可以以某种方式编辑此代码以执行迭代深化搜索?说限制2?我想不出一种方法来跟踪水平。

【问题讨论】:

    标签: java search iterative-deepening


    【解决方案1】:

    对于那些有兴趣的人,我在 Writing a DFS with iterative deepening without recursion 的帮助下解决了这个问题


    在我的实现中,我使用了一个带有节点键的哈希图和一个表示节点级别的整数作为值。

    【讨论】:

      猜你喜欢
      • 2018-08-26
      • 2017-05-28
      • 2021-01-10
      • 2017-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多