troubleshooting Question

# Binary trees in Scheme

Programming Languages-OtherPuzzles / RiddlesEncryption
I'm taking a computer class that uses Scheme and I'm having tons of trouble with the language. I've programmed with C++ and visual basic before so I understand the general idea of programming but I can never get the Scheme syntax right and a lot of the language is downright clunky. These are a few of the problems:

function 1
Develop the function inorder. It consumes a binary tree and produces a list of all the ssn numbers in the tree. The list contains the numbers in the left-to-right order

I don't know where to start with this one. I understand the physical aspect of the binary tree but not how to make one, much less put one in order.

I realize scheme is a icky old language, so if you need a point of reference, we're using an online book at
http://www.htdp.org/2003-09-26/

and I'm using the compiler Dr. scheme with the language beginning student with list abbreviations, if that's relevant at all. it's available at
``````;;class notes from for a binary tree. this is just an example of a binary tree, but I don't think it's applicable for this question. the example sort've helped me so I thought I'd post it

(define-struct bst (ssn left right))

(make-ssn 312045678)
(make-ssn 312012793)
(make-ssn 312459012)
(make-ssn 342147890)

(define (merge alon1 alon2)
(cond
[(empty? alon1) alon2]
[(empty? alon2) alon1]
[(< (first alon1) (first alon2))
(cons (first alon1) (merge (rest alon1) alon2))]
[else
(cons (first alon2) (merge alon1 (rest alon2)))]))

(define (make-singles l)
(cond
[(empty? l) '()]
[else (cons (list (first l)) (make-singles (rest l)))]))

(define (merge-neighbors alol)
(cond
[(empty? alol) '()]
[(empty? (rest alol)) alol]
[else (cons
(merge (first alol) (second alol))
(merge-neighbors (cddr alol)))]))

(define (merge-sort l)
(cond
[(empty? l) '()]
[else (repeat-merge (make-singles l))]))

(define (repeat-merge l)
(cond [(empty? (rest l)) (first l)]
[else (repeat-merge (merge-neighbors l))]))

(check-expect (merge-sort
'(5 3 4 9 2)) '(2 3 4 5 9))
``````
harfang
###### Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.