diff options
author | Ben Burwell <bburwell1@gmail.com> | 2013-04-11 00:03:50 -0400 |
---|---|---|
committer | Ben Burwell <bburwell1@gmail.com> | 2013-04-11 00:03:50 -0400 |
commit | 5b05b64a2a658c0f7d4eb5b09fa342c7375a776e (patch) | |
tree | bad4537081da8b969084cff6880e36418f13a97d /hw04_path.scm |
Init
Diffstat (limited to 'hw04_path.scm')
-rw-r--r-- | hw04_path.scm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/hw04_path.scm b/hw04_path.scm new file mode 100644 index 0000000..4d404fb --- /dev/null +++ b/hw04_path.scm @@ -0,0 +1,21 @@ +#lang scheme + +;; NAME: hw04_bintree.scm +;; AUTHOR: Ben Burwell +;; DESC: CSI310 - Programming Languages - Homework 4 - Binary Tree +;; HISTORY: Created 2013-02-11 + +(define path-helper + (λ (n bst pth) + [ (equal? (get-value bst) n) pth ] + [ (< n (get-value bst)) (cons 'left (path-helper n (get-left bst))) ] + [ (> n (get-value bst)) (cons 'right (path-helper n (get-right bst))) ] + )) + + +(define path + (λ (n bst) + (cond + [ (not (tree? bst)) 'not-a-tree ] + [ else (path-helper n bst '()) ] + )))
\ No newline at end of file |