我在使用二叉搜索树并将它们转换为列表时遇到问题。
(define-struct node (key val left right))
;; A binary search tree (bst) is either
;; empty, or
;; a structure (make-node k v l r), where
;; k is a number (the key),
;; v is a string (the value),
;; l is a bst, where every key in l is less than k, and
;; r is a bst, where every key in r is greater than k.
谁能给我提示如何解决这个问题?
创建一个使用二叉搜索树的函数 bst 并返回二叉搜索树节点的 value 字段中所有字符串的列表,该列表必须根据二叉搜索树中的键值降序排列。
;;Examples: (bst (make-node 4 "James" (make-node 2 "Kien" empty empty)
;;(make-node 5 "Jack" empty (make-node 11 "Cole" empty empty)))) => (list "Cole" "Jack" "James" "Kien")
谢谢!