Code: Select all
(define (predecessor element tree)
(cond
((null? tree) (node tree) ) ; If the tree is null result is the needed element
((> element (node tree)) (mem element (right-branch tree))); if the element is greater than node element, we search it in the right-branch tree
((< element (node tr)) (mem element (left-branch tree))) ; if element is lesser than node element, we search it in the left-branch tree
)
)