有人知道我为什么会收到这段代码的EVAL/APPLY: Too few arguments (1 instead of at least 2) given to INSERTBST
错误吗,谢谢。
(defun insertbst (E tree)
(cond ((null tree) (list E nil nil))
(( = E (car tree)) tree)
(( < E (car tree))
(list (car tree) (insertbst E (cadr tree))
(caddr tree)))
( t (list (car tree) (cadr tree) (insertbst E (caddr tree))))))
(print(insertbst'(8 (3 (1 () ()) (6 (4 () ())( 7 () ()))) (10 (()) (14 (13) ())))))
您应该用数字和树来调用它。顺便说一句,树中的一些节点没有两个后代,所以我纠正了这一点:
(insertbst 15 '(8 (3 (1 () ())
(6 (4 () ())
( 7 () ())))
(10 ()
(14 (13 () ())
()))))
=>(8 (3 (1 NIL NIL) (6 (4 NIL NIL) (7 NIL NIL))) (10 NIL (14 (13 NIL NIL) (15 NIL NIL))))