我正在尝试应用这个函数'add‘来将字符串列表转换为BST。( add函数只是插入一个术语)我的问题是如何定义fold,以便它将add函数应用于字符串,从而本质上逐个插入每个函数?我不确定哪里出了问题,但这给了我一个错误。: foldr1 (add x (add x Empty)) xs*** Type : BST*** Does not match : [Char] -&g
在练习包中找到的类BST包含用于插入和查找键值对的方法insert和find。这些方法利用两个递归助手方法_inserthelp和_findhelp来正常工作。您的任务是实现这些帮助方法。find_key)
"""Insert a new node with key new_key into this BSTif self.find(new_key) is not None:
raise KeyError(&
我正在尝试实现一个bst(二进制搜索树)在球拍。bst是一个递归列表(list X leftChild rightChild),其中leftChild和rightChild本身就是列表,我编写了以下代码 [(<= x (car bst)) (insert (cadr bst) x)]
[else (i