我有一棵树,我需要树的深度,但它不能工作。data Tree a b = Leaf a | Branch (b,Tree a b) (b,Tree a b) deriving(Eq,Show)
我的职能:depth (d,Branch a b) = 1 + (max (depth a) (depth b))
无法匹配预期类型的(t10, Treet20 t10)&
我想返回初始树的所有子树的列表,并给出参数的深度。当深度为0时,当深度与n匹配时,我尝试返回树的列表,我希望减少n,并使用我的函数和n参数对子树列表应用映射函数treemap f (Node x []) = Node (f x) []
treemap f (Node x l) = Node (f x) (map
我试图在python中找到BST的总深度(这样根深度是1,它的子深度是2,那些子深度是3,等等),总和是所有这些深度加在一起。我已经连续尝试了大约5个小时,但还是想不出答案。tree = BinarySearchTree() for i in arr:tree.searchPath(20)
print (tree.total_Depth()) #
= lxml.html.fromstring(html)
print(x) print('this should not happen', x)
我认为这是增加深度的最便宜的方法之一,这样做一次就会给所有元素以深度,而我只需要查看每个元素一次问题是,不知怎么的,它似乎不坚持.就像深度不附着在元素上一样