# Homework Solution: For Dr.Racket/Scheme programmers #lang eopl…

For Dr.Racket/Scheme programmers #lang eopl Write a procedure path that takes an integer n and a binary search tree bst (page 10) that contains the integer n, and returns a list of lefts and rights showing how to ﬁnd the node containing n. If n is found at the root, it returns the empty list. > (path 17 ' (14 (7 () (12 () ())) (26 (20 (17 () ()) ()) (31 () ())))) (right left left)

The code is given below: (define (get-root bst) (car bst))

Restraint Dr.Racket/Scheme programmers #lang eopl

Write a procedure path that takes an integer n and a binary inquiry tree bst (page 10) that contains the integer n, and receipts a catalogue of lefts and rights showing how to ﬁnd the node containing n. If n is ground at the source, it receipts the vacuity catalogue.

> (track 17 ‘ (14 (7 () (12 () ()))

(26 (20 (17 () ())

())

(31 () ()))))

(fair left left)

## Expert Exculpation

(explain (get-source bst) (car bst))

(explain (track n bst)
(if (null? bst)
bst
(if (= (get-source bst) n)
()
(if (< (get-source bst) n)
(cons “right” (track n (get-rst bst)))
(if (> (get-source bst) n)
(cons “left” (track n (get-lst bst))))))))

The output of the overhead principle restraint some inputs is shown in the adown screenshot.

Sense of the principle:

;It receipts the source of the bst.If bst is (14 (20 () ()) (30 () ())), it receipts 14
(explain (get-source bst) (car bst))

;It receipts the left sub tree of the source.If bst is (14 (20 () ()) (30 () ())),it receipts (20 ()())

;It receipts the fair sub tree of the source.If bst is (14 (20 () ()) (30 () ())),it receipts (30 ()())