我有以下的Node对象 class Node(object):
def __init__(parent=None, data)
self.__parent = parent
self.__data = data
self.__children = []
# parent and data properties getters and set
我被赋予作为一个任务来解决迷宫,使用球拍表示为一个隐式图。我想这样做,使用深度优先搜索和递归正在一路攀升到它必须返回,并按照不同的路径,在这里我得到的错误: application: not a procedure;
expected a procedure that can be applied to arguments
given: #<void>
arguments..
最近我遇到一个问题叫Gravity Tree 我无法自己解决,所以我检查了editorial。作者的解决方案是在顶点一次dfs并形成一个段树,其中每个节点包含从顶点到中心的距离。然后他提到了第二个dfs(我不知道这是做什么,我尝试打印他的数据结构,但他们完全没有意义,不知道他究竟想要做什么)。他写的语言太难以掌握了。我知道什么是细分树,dfs,懒散的传播。但是我无法围绕这个解决方案。不知道解决方案