【发布时间】:2015-11-02 03:16:39
【问题描述】:
我必须创建一个函数 bst-delete-max,它以二叉搜索树为参数并返回一棵二叉搜索树,其中包含从树中删除的最大值的节点。我不能使用任何找到最大值的辅助函数(bst-max)或辅助函数来删除节点(bst-delete)。因此,我完全不知道如何解决这个问题以及如何为它做任何事情。我知道无论我在哪里使用 bst-max,我都只需要编写函数来找到最大的最大值。但是我该如何删除它?任何帮助将不胜感激。这是我目前所拥有的:
(define (remove-max bs-tree)
(cond ((null? bs-tree)
'())
((null? (bst-right bs-tree))
(bst-value bs-tree)
(car bs-tree)) ;This is the part I know is wrong. How should I fix it?
(else (remove-max (bst-right bs-tree)))))
【问题讨论】:
-
我真的需要一些帮助。有人吗?
标签: list tree scheme binary-tree binary-search-tree